RewriteCond not working

Topics: Developer Forum
Jan 20, 2009 at 11:22 PM
Can someone please help me. If I run the following rule in Apache it works fine, when I attempt to run it in IIS it doesn't work at all.

# REDIRECT /subdirectory/index.htm to /subdirectory/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.htm\ HTTP/
RewriteRule ^(([^/]+/)*)index\.htm$ http://www.mywebsite.com/Home/$1 [R=301,L]

The purpose of the rule is if the user types in http://www.mysite.com/Home/index.htm
it will rewrite the URL to http://www.mysite.com/Home/

Can anyone explain if there is a difference in the way that regular expression are written in Ionics IIS? Or have I not set something up correctly in Ionic IIS?

Full code
-------------------------------------------------------------------
# IsapiRewrite4.ini
#
 
RewriteLogLevel 3
 
# REDIRECT /subdirectory/index.htm to /subdirectory/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.htm\ HTTP/
RewriteRule ^(([^/]+/)*)index\.htm$ http://www.mywebsite.com/Home/$1 [R=301,L]

# LETS ENSURE THAT ALL SUBDIRECTORIES END WITH A TRAILING SLASH WHEN REQUESTED
# SERVER DISPLAYS CONTENT OF /subfolder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !.html
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.mywebsite.com/$1/ [L,R=301]
-------------------------------------------------------------------

The second part which rewrite all URL's that do not include a html extension to ensure it finishes with a  /  doe not work either.

Appreciate all your help

Regards
zeroanarchy
Jan 21, 2009 at 4:15 AM
We have run the testdrive app and have had a look at the logs, this is what the log is telling us.

Log
----------------------------
Wed Jan 21 14:07:14 -  3464 - ReadConfig: setting LogLevel to 3
Wed Jan 21 14:07:14 -  3464 - ReadConfig: line  14: RewriteCond %{THE_REQUEST}^[A-Z]{3,9}\
Wed Jan 21 14:07:14 -  3464 - ParseCondModifierFlags: '/([^/]+/)*index\.htm\'
Wed Jan 21 14:07:14 -  3464 - WARNING: Badly formed RewriteCond modifier flags.
Wed Jan 21 14:07:14 -  3464 - ReadConfig: ERROR: compilation of RewriteCond expression '^[A-Z]{3,9}\' failed at offset 12: \ at end of pattern
----------------------------
Can anyone offer any advise.

Cheers
zeroanarchy