Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

301 redirect in .htaccess for unique IP address

Home page only not redirecting to www.site.com



2:14 am on Aug 2, 2006 (gmt 0)

10+ Year Member

I moved my sites to unique IP addresses, as recommended in this forum. After doing so, I edited my .htaccess files to redirect requests for each unique IP to the appropriate [domain] to prevent Google from indexing both the IP address and the [domain].

This worked fine on one web host. On another web host, all pages other than the home page are redirected when the IP address is typed into a browser command line. However, the home page is not redirected. Thus, for example, is redirected to http://www.example.com/contact.htm, but is not redirected, and appears in the browser command line instead of http://www.example.com/.

This is what the top of my .htaccess file looks like (FrontPage extensions). (The non-www to www and index.html to / redirects work fine.)


RewriteEngine on
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^12\.34\.56\.78
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$ http://www.example.com/ [R=301,L]

# -FrontPage-

IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*


Can anyone suggest a solution?

[edited by: jdMorgan at 3:03 am (utc) on Aug. 2, 2006]
[edit reason]
[1][edit reason] Example.com [/edit]


3:06 am on Aug 2, 2006 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Actually, that looks like it should work as-is, so let me ask a basic question: Did you explicitly flush your browser cache before testing?

There's no reason that your code (as shown) should differentiate between a request for "/contact.htm" and one for "/".

Once this main problem is fixed, however, I would suggest moving your current first rule below your current third rule, so that a double-redirect is not performed if "example.com/index.html" is requested.



Featured Threads

Hot Threads This Week

Hot Threads This Month