rewrite without querystring

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 5
Joined: 25 Mar 2013, 03:16

rewrite without querystring

25 Mar 2013, 03:21

I'm moving and php site to an asp site. Keeping the google result I use the Rewrite line for checking if the file index.php exists:

RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule [new-domain] [R=310]

This works fine but I still get the original querystring in the new site. Not a big problem (it does nothing) but how do I get rif of thies. Read sometihng about adding a questionmark but this will not work in this fashion.

thanx for your time and help
Walther

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

Re: rewrite without querystring

25 Mar 2013, 11:40

Hello,

To avoid querystring you need to add '?' at the end of the rule, as in following:

Code: Select all
RewriteRule aaa bbb? [R=301]


Regards
Andrew

User avatar
Posts: 5
Joined: 25 Mar 2013, 03:16

Re: rewrite without querystring

25 Mar 2013, 14:10

The questionmark works when there is a source and a destination. in the rewrite rule I use I only have a destination and adding the questionmark makes no difference.

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

Re: rewrite without querystring

25 Mar 2013, 15:20

Not sure I've ever used this technique in the last 3 years. Would you give me an example of incoming and resulting request of such a rule?
The essence of a rule is to get input and create new output, so I assume we'd be able to re-do your rule and apply '?' anyway.

Regards
Andrew

User avatar
Posts: 5
Joined: 25 Mar 2013, 03:16

Re: rewrite without querystring

26 Mar 2013, 12:08

http://www.matgames.fr/index.php?option=com_virtuemart&Itemid=122

it was a PHP site and now it rewritten into ASP. So I check for the existince of the file index.php. On the new site it don't exist so I rewrite the call to the home page of the new site (same domein: www.matgames.fr); only want to strip the querystring.

This works:
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule http://www.matgames.fr [R=301]

but leaves the querystring intact

thanx
with regards Walther

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

Re: rewrite without querystring

26 Mar 2013, 15:06

I'm not sure you're working on the right rule.
This rule you provided checks of the requested URI is, in fact, REAL!

Code: Select all
RewriteCond %{REQUEST_FILENAME} -f


The condition that would check if he file doesn't exist is

Code: Select all
RewriteCond %{REQUEST_FILENAME} !-f


So in your case the rule should look like:

Code: Select all
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* http://www.matgames.fr? [NC,R=301,L]


In this case whatever request has been made will be checked, and it such file doesn't exist - redirect to a new domain

Regards
Andrew

User avatar
Posts: 5
Joined: 25 Mar 2013, 03:16

Re: rewrite without querystring

27 Mar 2013, 03:05

thanx a lot; it works. What a difference one character can make ;-)

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 15 guests