add .html except for root/

ISAPI_Rewrite is a powerful URL manipulation engine based on regular expressions
User avatar
Posts: 9
Joined: 27 Mar 2012, 22:41

add .html except for root/

09 May 2012, 01:43

Hi

I currently add .html to urls except for css, js, etc, however if I want to connect to the index page of the root i.e. my domain.com/ .html is being added to the request. How do I stop this from happening.

This is what I currently have:


[ISAPI_Rewrite]

RewriteEngine on

RewriteBase /

RewriteRule /httpd(?:\.ini|\.parse\.errors) / [F,I,O]

RewriteRule .*\.isrwhlp / [F,I,O]

RewriteCond %{REQUEST_METHOD} !^POST$ [NC]
RewriteRule ^([^?]+)\/$ $1 [NC,R=301,L]

RewriteCond %{REQUEST_METHOD} !^POST$ [NC]
RewriteRule ^([^?]+)\.html$ $1 [NC,R=301,L]

#Internally add extensions to request
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule (?!.*\.(?:css|jpg|js|png))(.*) $1.html

THANKS :)

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: add .html except for root/

10 May 2012, 05:26

Hello,

I believe you have ISAPI_Rewrite 3, right?

Then let's try to fix it the following way:

RewriteEngine on
RewriteBase /

RewriteRule ^$ - [NC,L]

RewriteCond %{REQUEST_METHOD} !^POST$ [NC]
RewriteRule ^([^?]+)/$ $1 [NC,R=301,L]

RewriteCond %{REQUEST_METHOD} !^POST$ [NC]
RewriteRule ^([^?]+)\.html$ $1 [NC,R=301,L]

#Internally add extensions to request
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(?!.*\.(?:css|jpg|js|png))(.*) $1.html [NC,L]

User avatar
Posts: 16
Joined: 19 Nov 2012, 22:21

Re: add .html except for root/

19 Nov 2012, 22:38

I am currently on rewrite 3. I will try this fix and hope it works.

Return to ISAPI_Rewrite 2.x

Who is online

Users browsing this forum: No registered users and 1 guest