Forum Moderators: phranque
#######################################################
# remove index.htm/html from url
# rewrite non-www into www
#
# RULE A = combine both lack of www and presence of index
# RULE B = only lackof www
# RULE C = presence of index (htm or html)
######################################################
#rule A
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{REQUEST_URI} ^(.*/)(index\.html|index\.htm)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
#rule B
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
#rule C
RewriteCond %{REQUEST_URI} ^(.*/)(index\.html|index\.htm)$ [NC]
RewriteRule . %1 [R=301,NE,L]
This was working as intended up to a few days ago.
Now this rule fails in IE8-IE11 and in Opera but keeps working in other browsers in my PC (FF, Chrome,Safari).
[edited by: incrediBILL at 3:14 am (utc) on Jul 15, 2014]
[edit reason] fixed links [/edit]
Not sure why you need three rules to accomplish what you may in one.
[edited by: penders at 3:49 pm (utc) on Jul 14, 2014]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
RewriteRule ^(.*)index\.html$ /$1 [R=301,L] RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
I understand that htaccess is executed in server and is irrelevant to the user's browsers.
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
The htacceess is 170kb, so yeah.. too many rules inside.
As for the responce.. "Could not locate remote server"
For Chrome (v.35) i get this response :
On Firefox (v.30) i get this (using live http headers plugin)
http://www.example.com/some-page.htm
How do you know there isn't a conflict with another directive?
Are you getting this error on the initial request (ie. before the server has responded with a redirect) or on the second request, after the server has responded with the redirect?
These are actually the request headers, not the response headers
You need to test "http://example.com/some-page.htm" (ie. without the www)