Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I am experimenting with the PHP redirect

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.

share|improve this question
It's not mentioned in your linked article, but the header() function has a 3rd argument where you can specify the HTTP status code (ie. 301). See the PHP Docs: – w3d Aug 14 '13 at 19:04

1 Answer 1

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:


If you only wanted to pass certain variables, you could get them individually and then append them in a similar way:

share|improve this answer
Just to note, values in the $_GET array are already URL decoded. So these should be validated and possibly urlencode()d before building the URL. In fact it is advisable to validate everything you are 'passing back' to the URL. – w3d Aug 14 '13 at 18:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.