The Correct 301 Redirect to a New Domain

 

I have found a few different example on the web. The first one I used added a big, long, unnecessary query string to the url. The following one works without a hitch. Just change the .htaccess file in the main folder of your site to one containing this text. Of course, replace yournewdomain.com to the one you are redirecting to.

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.yournewdomain.com/$1 [R=301,L]

Tags: ,


Stephan Miller

Written by

Kansas City Software Engineer and Author

Twitter | Github | LinkedIn

Updated