Mobile app version of vmapp.org
Login or Join
Murray432

: 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

@Murray432

Posted in: #Php #Redirects #UrlParameters

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.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Murray432

1 Comments

Sorted by latest first Latest Oldest Best

 

@Rambettina238

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"]);

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme