I am rebranding a website, which involves changing the domain name. I want to know the best way of redirecting traffic to the new domain, using 301. Ideally, I will do this at the webserver (Apache) level, rather than at the page level.

There are lots of articles on Google - but I would like to hear from people who have actually undergone such a transition - so I know if there are any gotchas etc to be aware of.


Just make sure you redirect users to the same page on the new domain that they were expecting on the old domain. If the page no longer exists then you should take the user to as page that explains why the page has been removed and recommend other pages that may be related or are otherwise helpful to the user. Although search engines will update their indexes in a set period of time, users may not update their bookmarks so you should leave the 301 redirects up for an extended period of time if not indefinitely.


Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
  • Thanks for the response. I probably didn't make this clear in my question. I was looking for a more technical explanation as to what needs to happen (e.g. enter a line in a particular Apache configuration file etc.) Dec 16 '11 at 17:33
  • That's easy enough to do. Assuming the URL structure is not changing just use the code in my updated answer.
    – John Conde
    Dec 16 '11 at 18:32
  • One important thing to do, though it may seem obvious - is check the response using httpfox or similar. Whether you do it in the server config, .htaccess or on the page itself (all of which are valid), its easy to make a typo and end up serving a page that would tell a USER its gone, but without giving the correct 301 signal to robots to tell them its gone too. If you have a redirect but you're still serving 200, the page will never get de-indexed. Obvious, but i've seen it happen (and done it myself).
    – Codecraft
    Dec 17 '11 at 1:33
  • @Codecraft could you elaborate some more on this part of your comment: "If you have a redirect but you're still serving 200, the page will never get de-indexed. Obvious, but i've seen it happen (and done it myself)" ?. I thought that modifying the config file will prevent the page ever being served by Apache - am I missing something? Dec 17 '11 at 15:08
  • Well, there's more than one way to put a redirect in - an Apache's config directly, in .htaccess and in page code. I was merely pointing out that its easy to make a typo (particularly in page code) that means the redirect doesn't work as you think it should be. Just saying its an area where its worth double checking your work :)
    – Codecraft
    Dec 17 '11 at 23:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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