PHP header redirect that maintains query parameters?
PHP header redirect that maintains query parameters? - 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 PHP header redirect that maintains query parameters? error on your web browser. Problem :
Solution :
We hope that this article has helped you resolve the php, redirects, url-parameters error in your web browsers. Enjoy browsing the internet uninterrupted!
I am experimenting with the PHP redirect http://www.phpjunkyard.com/tutorials/php-redirect.php.
Specifically the 301 redirect to create a self correcting URL to help with typos - there's a unique ID in the URL as well that needs to be correct for it to work.
Can I still allow for analytics tracking parameters e.g. tracking=yes ?
Currently the rewrite strips this out.
If you wanted to append all the query parameters you would want to use $_SERVER['QUERY_STRING'] to extract them from the current URL, you would then append this to the location of the redirect:
header("Location: http://www.New-Website.com?".$_SERVER['QUERY_STRING']);
If you only wanted to pass certain variables, you could get them individually and then append them in a similar way:
header("Location: http://www.New-Website.com?tracking=".$_GET["tracking"]);
Comments
Post a Comment