Temporary redirect needs to detect the URL of original page request from a search engine then redirect again to that page

Temporary redirect needs to detect the URL of original page request from a search engine then redirect again to that page - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the Temporary redirect needs to detect the URL of original page request from a search engine then redirect again to that page error on your web browser. Problem :


When you come to my client's site, it needs to verify that you are 21 years of age of older. If you hit any page on the domain, it checks to see if the verified age cookie is set. If not, it takes you to a challenge page to give your date of birth, after which it forwards you to the index page (or a rejection page, if you answered incorrectly).



The problem I have run into is as follows:

If a user finds any one of the pages in a search engine, after they pass the age test, how do I send them back to page they were originally requesting?



Example:

User finds www.example.com/blog.php in Google, after clicking the link, they are redirected to www.example.com/age_verify.php. After they pass the test, how do I send them back to www.example.com/blog.php instead of the default www.example.com?



I'm flummoxed. I'm pretty sure I'm dealing with HTTP referrers, but I don't know in what capacity.


Solution :

Don't rely on the referrer. You can store the URL as a query string parameter, or as a session parameter.




  1. User hits blog.php. This page checks for the age cookie.

  2. If age cookie not present, store current URL as a query string parameter like this - /age_verify.php?returnURL=blog.php. Alternatively, store the url in a session parameter.

  3. Redirect the user to age_verify

  4. After verifying age, extract the url from either the query string, or from the session, and perform another redirect.



In age_verify.php you must save $_SERVER['HTTP_REFERER'] which is the referer in a variable, say $referer.



There are multiple ways to take it from there but one simply way is that you set the cookie
and call age_verify.php?ref=$referer (easy to do through a GET form).



Before ANY output is made from age_verify.php it must check the cookie and if it is there, redirect to $referer. This is done using header("Location: $referer").


We hope that this article has helped you resolve the redirects, cookie, age-verification error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

"302 found" for index page bad for SEO?

Create redirect from url like www.example.us/?p=100&option=