Chris
Chris

Reputation: 6182

How to remove unwanted subdomain with .htaccess?

For whatever reason, my client's site is showing up in Google with a competitors phone number in the subdomain. Not all results, but several results are showing it now.

So what should be www.clientsite.com is coming up with www.800-555-1212www.clientsite.com

How do I set my .htaccess to keep it just as www.clientsite.com?

Upvotes: 1

Views: 2161

Answers (2)

GolezTrol
GolezTrol

Reputation: 116120

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.clientsite\.com
RewriteRule .* http://www.clientsite.com/$0 [redirect=permanent,L]

Upvotes: 3

Chris
Chris

Reputation: 6182

I've found that this works

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.clientsite\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9-]+)\.clientsite\.com$ [NC]
RewriteRule .* http://www.clientsite/$0 [redirect=permanent,L]

Upvotes: 0

Related Questions