Forum Moderators: Robert Charlton & goodroi
I just discovered that Google has listings for my site's IP address (rather than url), which may trigger dup. content filter.
I suggest that if folks are on unique IP addresses, they do a search for site:your.ip.numbers.here - if you find any listings, add a 301 redirect to your .htaccess file.
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^your\.ip\.numbers\.here [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] [edited by: ciml at 9:12 am (utc) on June 16, 2005]
[edit reason] Examplified [/edit]
>I just discovered that Google has listings for my site's IP address (rather than url), which may trigger dup. content filter.
I suggest that if folks are on unique IP addresses, they do a search for site:your.ip.numbers.here - if you find any listings, add a 301 redirect to your .htaccess file.<
Thanks. That underline again the importance of adding a 301 redirect (which has been discussed on several threads).
It has been mentioned many times before.
But once again here is a proper redirect ruleset for servers on port 80 (default) and running Apache.
RewriteEngine On
# prevent uncovering files in a directory without a valid index file
Options -Indexes
# prevent the uncovering of a valid index file
rewriteCond %{THE_REQUEST} ^.*\/index\.shtml
rewriteRule ^(.*)index\.shtml$ http://www.example.com/$1 [R=301,L]
# You need one of these for each valid index type you allow to be an index page
# redirect all valid aliases to the www form
RewriteCond %{HTTP_HOST}!^www\.example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Note the RewriteCond is for all valid aliases and even would cover properly parked vanity domains (warning depending on a number of factors parked vanity domains may be far more trouble than you want).
Please watch out for forum software mangling posting of such items. I did bracket the code with code container markup.
Oh and for folk using cPanel/WHM the hotlink protection has been known to blow away the contents of .htaccess when activated or deactivated, and it also appears that just clicking on that icon will activate it.
RewriteEngine On
# prevent uncovering files in a directory without a valid index file
Options -Indexes
# prevent the uncovering of a valid index file
# (you need one of these for each valid index type you allow to be a index page)
RewriteCond %{THE_REQUEST} /index\.shtml
RewriteRule ^(.*)index\.shtml$ http://www.example.com/$1 [R=301,L]
# redirect all valid aliases to the www form
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Jim
Even though hitting my sites with both http 1.0 and 1.1 clients casued no problems.
I also agree with Jim saying to drop the [NC] even though the standards say that the Host is not case sensitive.
Who knows what someone will do to mess up the works.
And you should remember that even this is not the best way to handle hostname issues.
This is second best.
First is a proper server setup only allowing one visable server alias.
Jim, thank you for your information and time, it will help plug even more holes.
In my .htaccess file, i have statements that look like this:
redirect 301 /index.htm [mydomain.com...]
redirect 301 /dirt.htm [mydomain.com...]
...etc. Now, how do I have it to 301 redir requests for the IP address to the domain name? Is it like:
redirect 301 [mydomain.com...]
...or...
redirect 301 ip.address [mydomain.com...]
Thanks,
Dave
redirect 301 / [mydomain.com...]
...'cause it would redirect the IP entry to the top domain. But, when I performed the "Server Header Check", it not only reported that the IP address had moved to www.mydomain.com, it reported that www.mydomain.com had moved to www.mydomain.com, hehehheheh... Any ideas on how to correctly write the .htaccess string?
Thanks,
Dave