Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Our web developers are using JavaScript redirects - first of all this does not work well for SEO and secondly, it does not preserve the http_referrer (therefore it does not show up in our web stats). So I'd like to get a 301 redirect in Apache, but I want to ensure the referrer will be passed along.

Does anyone know how to preserve the referrer with 301 redirects in Apache?

Will a 301 redirect with mod_rewrite preserve the referrer by default? Or do I need to use some custom code with mod_rewrite?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

You can do 2 things in your apache VirtualHost config:

But i think when you have to many rewrites you should write the rewrites to a .htaccess file.

share|improve this answer
    
Actually, just the opposite. Have a look at this under the section "When not to use .htaccess": httpd.apache.org/docs/2.0/howto/htaccess.html. If you have access to the Apache config files, it is better to use that instead of .htaccess files. Overall performance is better when not using .htaccess files. –  Rob May 30 '11 at 12:15
    
Will this preserve the referrer, so when the user lands on www.askdavetaylor.com, they use the right referrer? –  Robert Kingston May 31 '11 at 1:08
    
Ignore my comment above. I have discovered the rewrite method above does preserve the referrer... –  Robert Kingston May 31 '11 at 5:10

Your Answer

 
discard

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.