Forum Moderators: phranque
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, http://12.34.56.78/contact.htm is redirected to http://www.example.com/contact.htm, but http://12.34.56.78 is not redirected, and http://12.34.56.78/ 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] [/edit][/1]
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.
Jim