: PHP header redirect that maintains query parameters? I am experimenting with the PHP redirect http://www.phpjunkyard.com/tutorials/php-redirect.php. Specifically the 301 redirect to create a self correcting
I am experimenting with the PHP redirect 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.
More posts by @Murray432
1 Comments
Sorted by latest first Latest Oldest Best
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: 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: www.New-Website.com?tracking= .$_GET["tracking"]);
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.