Simple Query String Question

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 1
Joined: 09 Jun 2014, 13:01

Simple Query String Question

09 Jun 2014, 15:46

Hello,

I am trying to rewrite an expresion like this:

domainname/cgi-bin/demo/dir1/?var1=value1&var2=value2


into something like:

domainname/dir1/?var1=value1&var2=value2

I have this:
RewriteCond %{QUERY_STRING} ^(\d+)$ [NC]
RewriteRule ^cgi-bin/demo/dir1/$ /dir1/%1 [NC,L]



->In other words I am trying to hide (or change the real file location) sending the same querystring to the dir1 directory


thanks in advance for your kind help


Ben

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Simple Query String Question

10 Jun 2014, 23:56

Hello,

If all you need is a clean redirect:

Code: Select all
RewriteRule ^cgi-bin/demo/dir1/$ /dir1/ [NC,R=301,QSA,L]

but you'd probably need a second part:
Code: Select all
RewriteCond %{QUERY_STRING} ^var1=\d+&var2=.*$ [NC]
RewriteCOnd %{REQUEST_FILENAME} !-f
RewriteCOnd %{REQUEST_FILENAME} !-d
RewriteRule ^dir1/$ /cgi-bin/demo/dir1/ [NC,QSA,L]


Regards

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 0 guests