Convert mod_rewrite rules to IIRF

Topics: Developer Forum, Project Management Forum, User Forum
Jul 8, 2009 at 9:22 AM

Hello, i'am sorry for my bad english. I need help with convert url rewrite rules from apache's mod rewrite to IIRF. Here is my rules:

RewriteEngine on

#RewriteCond %{REQUEST_URI} !.*\..*$
RewriteRule ^(novinky)/?([^/]+)?/?([^/]+)?/?([^/]+)?/?([^/]+)?/?$ /index.php?par1=$1&par2=$2&par3=$3&par4=$4&a=%{REQUEST_URI} [L,QSA]
RewriteRule ^(mapa)/?([^/]+)?/?([^/]+)?/?([^/]+)?/?([^/]+)?/?$ /map.php?par1=$1&par2=$2&par3=$3&par4=$4&a=%{REQUEST_URI} [L,QSA]

RewriteRule ^(pouzite-kompresory)/?([^/]+)?/?([^/]+)?/?([^/]+)?/?([^/]+)?/?$ /index.php?par1=$1&par2=$2&par3=$3&par4=$4&a=%{REQUEST_URI} [L,QSA]
RewriteRule ^(pujcovna-kompresoru)/?([^/]+)?/?([^/]+)?/?([^/]+)?/?([^/]+)?/?$ /index.php?par1=$1&par2=$2&par3=$3&par4=$4&a=%{REQUEST_URI} [L,QSA]

RewriteRule ^(admin)/?([^/]+)?/?([^/]+)?/?([^/]+)?/?([^/]+)?/?$ /private/index.php?par1=$1&par2=$2&par3=$3&par4=$4&a=%{REQUEST_URI} [L,QSA]

RewriteRule ^(poptavka-zarizeni)/?([^/]+)?/?([^/]+)?/?([^/]+)?/?([^/]+)?/?$ /napiste-nam.php?par1=$1&par2=$2&par3=$3&par4=$4&a=%{REQUEST_URI} [L,QSA]
RewriteRule ^(poptavka)/?([^/]+)?/?([^/]+)?/?([^/]+)?/?([^/]+)?/?$ /napiste-nam.php?par1=$1&par2=$2&par3=$3&par4=$4&a=%{REQUEST_URI} [L,QSA]

RewriteRule ^([^/\.]+)/?$ /index.php?par1=$1 [QSA,L]

ErrorDocument 404 /error404.php

 

Can someone help me? If someone convert it I will be very cheerful. Thanks a lot.

Coordinator
Jul 8, 2009 at 6:01 PM
Edited Jul 8, 2009 at 6:03 PM

First, there is no RewriteEngine statement supported in IIRF.  Also, no ErrorDocument.  You can set the Error doc in the IIS configuration.

in IIS the URL begins with a slash.  For each of your rules, following the circumflex (^), you should insert a slash.

In IIRF there is no QSA flag, so for each of your rules you will have to remove it.  It doesn't look like you are using it anyway.  (If you know what QSA does, then I guess you know what I mean).

Also, the server variable REQUEST_URI - I think you can swap that with URL.

This is a first cut. 

RewriteRule ^/(novinky)/?([^/]+)?/?([^/]+)?/?([^/]+)?/?([^/]+)?/?$               /index.php?par1=$1&par2=$2&par3=$3&par4=$4&a=%{URL}          [L] 
RewriteRule ^/(mapa)/?([^/]+)?/?([^/]+)?/?([^/]+)?/?([^/]+)?/?$                  /map.php?par1=$1&par2=$2&par3=$3&par4=$4&a=%{URL}            [L] 
RewriteRule ^/(pouzite-kompresory)/?([^/]+)?/?([^/]+)?/?([^/]+)?/?([^/]+)?/?$    /index.php?par1=$1&par2=$2&par3=$3&par4=$4&a=%{URL}          [L] 
RewriteRule ^/(pujcovna-kompresoru)/?([^/]+)?/?([^/]+)?/?([^/]+)?/?([^/]+)?/?$   /index.php?par1=$1&par2=$2&par3=$3&par4=$4&a=%{URL}          [L] 
RewriteRule ^/(admin)/?([^/]+)?/?([^/]+)?/?([^/]+)?/?([^/]+)?/?$                 /private/index.php?par1=$1&par2=$2&par3=$3&par4=$4&a=%{URL}  [L] 
RewriteRule ^/(poptavka-zarizeni)/?([^/]+)?/?([^/]+)?/?([^/]+)?/?([^/]+)?/?$     /napiste-nam.php?par1=$1&par2=$2&par3=$3&par4=$4&a=%{URL}    [L] 
RewriteRule ^/(poptavka)/?([^/]+)?/?([^/]+)?/?([^/]+)?/?([^/]+)?/?$              /napiste-nam.php?par1=$1&par2=$2&par3=$3&par4=$4&a=%{URL}    [L] 
RewriteRule ^/([^/\.]+)/?$                                                       /index.php?par1=$1                                           [L] 

But this may not be exactly what you want. It helps to have some example input and output URLs. like so:

original rewritten to
/novinky/aaa /index.php?par1=novinky&par2=aaa&par3=&par4=&a=/novinky/aaa
/novinky/aaa/ /index.php?par1=novinky&par2=aaa&par3=&par4=&a=/novinky/aaa/
/novinky/aaa/bbb /index.php?par1=novinky&par2=aaa&par3=bbb&par4=&a=/novinky/aaa/bbb
/novinky/aaa/bbb/ /index.php?par1=novinky&par2=aaa&par3=bbb&par4=&a=/novinky/aaa/bbb/
/novinky/aaa/bbb/ccc /index.php?par1=novinky&par2=aaa&par3=bbb&par4=ccc&a=/novinky/aaa/bbb/ccc
/novinky/aaa/bbb/ccc/ /index.php?par1=novinky&par2=aaa&par3=bbb&par4=ccc&a=/novinky/aaa/bbb/ccc/
/novinky/aaa/bbb/ccc/ddd /index.php?par1=novinky&par2=aaa&par3=bbb&par4=ccc&a=/novinky/aaa/bbb/ccc/ddd
/novinky/aaa/bbb/ccc/ddd/ /index.php?par1=novinky&par2=aaa&par3=bbb&par4=ccc&a=/novinky/aaa/bbb/ccc/ddd/
/novinky/aaa/bbb/ccc/ddd/eee NO REWRITE
/novinky/aaa/bbb/ccc/ddd/eee/ NO REWRITE

If you have that, then you can plug it into the testdriver.exe to verify that your rules are doing what you want them to do.

You should get the latest vevrsion of IIRF to make sure this works for you. (I just updated it to R8)

 

Coordinator
Jul 8, 2009 at 10:22 PM

There is now a QSA modifer, in v1.2.16 of IIRF.

I still don't think you need it.

Jul 9, 2009 at 6:45 AM

It's running!!! Thank you very much for your time :-)