Return to Snippet

Revision: 8291
at February 19, 2009 06:10 by DaveChild


Updated Code
RewriteCond %{REQUEST_METHOD}  ^(GET|HEAD) [NC] # Only rewrite GET requests
RewriteCond %{HTTP_HOST} olddomain\.com [NC] 
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} olddomain\.com [NC] # Otherwise block
RewriteRule ^(.*)$ - [F]

Revision: 8290
at September 11, 2008 11:11 by DaveChild


Initial Code
RewriteCond %{REQUEST_METHOD}  ^GET [NC] # Only rewrite GET requests
RewriteCond %{HTTP_HOST} olddomain\.com [NC] 
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} olddomain\.com [NC] # Otherwise block
RewriteRule ^(.*)$ - [F]

Initial URL

                                

Initial Description
Redirect all GET and HEAD requests to new domain (only redirecting GET and HEAD because POST, PUT, DELETE etc to old domain is almost certainly automated spam - no genuine users should ever be posting to old domain if it's been completely redirected). Serve 403 to any other request.

Initial Title
mod_rewrite Redirect Domain (Only GET + HEAD)

Initial Tags

                                

Initial Language
Apache