Using .htaccess to redirect a page with permanently moved 301

Though there are many ways to redirect using the HTTP 301 status code.

(make sure the AllowOverride is set to all on the apache config)

The .htaccess must be as follows:

Options +FollowSymlinks
 RewriteEngine on
 rewritecond %{http_host} ^orig.domain.com [nc]
 rewriterule ^(.*)$ http://new.domain.com/
 $1 [r=301,nc]

Replace the orig.domain.com and new.domain.com with the ones needed for your case of course.

You can setup logs for checking the rewriting though be warned enable them only when debugging they are hugely intensive on I/O and CPU on a heavy utilised server.

More info here : http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritelog

Leave a Reply

Your email address will not be published. Required fields are marked *