Please help me to convert .htaccess to IsapiRewrite4.ini

Topics: Developer Forum, User Forum
Jun 10, 2009 at 10:16 PM
Edited Jun 11, 2009 at 3:01 AM

 

I need to convert .htaccess to IsapiRewrite4.ini in order to run URL optimize feature of Elxis cms on IIS.

Normally they use Apache,but IIS is also supported with IIRF.

The syntax of .htaccess and IsapiRewrite4.ini looks quite similar,so I tried to copy/paste their default .htaccess  into IsapiRewrite4.ini but it doesn't seem to work.

See log here

IIRF Log

Their htaccess file is here

htaccess


Can somebody help me out to convert it  ?

Thanks for all your help.

 

 

 

 

Coordinator
Jul 8, 2009 at 11:32 PM

Here is a pretty good start. You will need to test it. Also, be sure to get v1.2.16 of IIRF, which is the first release with the QSA modifer.

# IsapiRewrite4.ini
#
# ini file for the ISAPI rewriter. 
# 

 RewriteLog  c:\temp\iirf-v1.2.15.log
 RewriteLogLevel 5

#RewriteCond %{QUERY_STRING} (?!mylang=(arabic|armenian|bosnian|creole|croatian|danish|dutch|english|french|german|greek|hebrew|indonesian|italian|japanese|latvian|lithuanian|persian|polish|romanian|russian|serbian|spanish|srpski|turkish|vietnamese))

# Rule #1 - don't redirect if mylang is set
RewriteCond %{QUERY_STRING} (mylang=(arabic|armenian|bosnian|creole|croatian|danish|dutch|english|french|german|greek|hebrew|indonesian|italian|japanese|latvian|lithuanian|persian|polish|romanian|russian|serbian|spanish|srpski|turkish|vietnamese))
RewriteRule ^/(.*)$  -    [L]


## if any URLS get this far, mylang is not set

RewriteRule ^/ar/(.*)$     /index.php?mylang=arabic     [QSA,I,L]
RewriteRule ^/hy/(.*)$     /index.php?mylang=armenian   [QSA,I,L]
RewriteRule ^/bs/(.*)$     /index.php?mylang=bosnian    [QSA,I,L]
RewriteRule ^/pt-BR/(.*)$  /index.php?mylang=brazilian  [QSA,I,L]
RewriteRule ^/ht/(.*)$     /index.php?mylang=creole     [QSA,I,L]
RewriteRule ^/hr/(.*)$     /index.php?mylang=croatian   [QSA,I,L]
RewriteRule ^/da/(.*)$     /index.php?mylang=danish     [QSA,I,L]
RewriteRule ^/nl/(.*)$     /index.php?mylang=dutch      [QSA,I,L]
RewriteRule ^/en/(.*)$     /index.php?mylang=english    [QSA,I,L]
RewriteRule ^/fr/(.*)$     /index.php?mylang=french     [QSA,I,L]
RewriteRule ^/de/(.*)$     /index.php?mylang=german     [QSA,I,L]
RewriteRule ^/el/(.*)$     /index.php?mylang=greek      [QSA,I,L]
RewriteRule ^/he/(.*)$     /index.php?mylang=hebrew     [QSA,I,L]
RewriteRule ^/id/(.*)$     /index.php?mylang=indonesian [QSA,I,L]
RewriteRule ^/it/(.*)$     /index.php?mylang=italian    [QSA,I,L]
RewriteRule ^/ja/(.*)$     /index.php?mylang=japanese   [QSA,I,L]
RewriteRule ^/lv/(.*)$     /index.php?mylang=latvian    [QSA,I,L]
RewriteRule ^/lt/(.*)$     /index.php?mylang=lithuanian [QSA,I,L]
RewriteRule ^/fa/(.*)$     /index.php?mylang=persian    [QSA,I,L]
RewriteRule ^/pl/(.*)$     /index.php?mylang=polish     [QSA,I,L]
RewriteRule ^/ro/(.*)$     /index.php?mylang=romanian   [QSA,I,L]
RewriteRule ^/ru/(.*)$     /index.php?mylang=russian    [QSA,I,L]
RewriteRule ^/sr/(.*)$     /index.php?mylang=serbian    [QSA,I,L]
RewriteRule ^/es/(.*)$     /index.php?mylang=spanish    [QSA,I,L]
RewriteRule ^/rs/(.*)$     /index.php?mylang=srpski     [QSA,I,L]
RewriteRule ^/tr/(.*)$     /index.php?mylang=turkish    [QSA,I,L]
RewriteRule ^/vi/(.*)$     /index.php?mylang=vietnamese [QSA,I,L]


# Don't rewrite URLS that begin with these strings
RewriteRule ^/(administrator|bridges|cache|components|editor|help|images|includes|language|mambots|media|modules|templates|tmpr)/ - [L]

# If the file or dir doesn't exist, go to the index page
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*) index.php    [L]

RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [I,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule ^/(.*)$ index.php [F,L] 

Just a few comments on the original rewrite rules...
You had a bunch of regular expressions that didn't make any sense. You had things like ([ar]{2}) when what you really wanted was just ar. The former - what you had - means a sequence of 2 characters, each one is either an 'a' or an 'r'. I am pretty sure what you intended was to match just 'ar'. Also, I am guessing you had the rule for pt-br (brazilian) commented out in the ruleset because it didn't work as expected. The reason it didn't work is because it was a bogus regex. The one I have provided above is better - it's what you intended, I'm sure.

Also you don't need to capture the 2-character language code, so I removed the parens.

I didn't bother debugging the final rule. It has a bunch of matching on the QUERY_STRING, and I'm not interested in spending time to see if it makes sense. I suppose you know what it does. No need to change any of those for IIRF, except change the "NC" modifer to "I", for case-insensitive matching.