/ Published in: Apache

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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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]
Comments
