0

We have a website that has been listed on Google with the original holding domains (stage, prod, etc)

We need to return a 410 to google and other bots for specific subdomains, but also rewrite other sub-domains to www (excluding other specifics, such as careers., covid. and contact.

Does this look correct (if we get it wrong then we risk getting de-listed from Google!)

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(dev|stage|prod)\. [NC]
RewriteCond %{HTTP_USER_AGENT} Googlebot|Baidu|Bingbot|DuckDuckBot|Slurp|Yandex [NC]
RewriteRule (.*) - [R=410,L]

RewriteCond %{HTTP_HOST} !^(www|careers|covid|contact)\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule (.*) https://www.mydomain.co.uk%{REQUEST_URI} [L,NE,R=301]

Many thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.