Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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 ^(.*)$$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