Skip to content

Instantly share code, notes, and snippets.

@DaveChild
Created July 24, 2009 11:33
Show Gist options
  • Save DaveChild/154029 to your computer and use it in GitHub Desktop.
Save DaveChild/154029 to your computer and use it in GitHub Desktop.
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). Ser
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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment