Navigate/Search

Use mod_rewrite to redirect one domain to another via GET

Dave Child ran into this problem a while back when the idiotic Jack Daniels corporation decided to flex its mighty talons.

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]

Redirect all GET requests to new domain (only redirecting GET because POST 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. — Dave Child

Comments are closed.