Forum Moderators: Robert Charlton & goodroi
I have discovered that my site has been indexed both under domain name and IP address. Exactly how this happened I'm not sure. I 'think' this happened last year during a server move when I decided to run my forum under IP address to prevent messages from being posted both at new and old server during DNS update - big mistake.
Can you use a robots.txt file to remove indexed pages by IP address? If not, will a 301 in my .htaccess file work? I don't know if it's possible to redirect for IP to domain name. If so, a code snippet would greatly be appreciated.
thanks,
Devvy
RewriteEngine on
RewriteCond %{HTTP_HOST}!^www\.example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]
And I think I'm learning how these rewrite conditions work.
I had a few lines already to deal with the www / none www issue but mine only looked for the domain, I didn't know you could do wild cards like yours.
I edited your snippet to this so that both IP and non www would get handled and it's working.
RewriteCond %{HTTP_HOST}!^.*\.mydomain\.com
RewriteRule ^(.*)$ [mydomain.com...] [R=301,L]
thanks again,
devvy