rewrite without querystring
7 posts
• Page 1 of 1
rewrite without querystring
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
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
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: rewrite without querystring
Hello,
To avoid querystring you need to add '?' at the end of the rule, as in following:
Regards
Andrew
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
Re: rewrite without querystring
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.
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: rewrite without querystring
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
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
Re: rewrite without querystring
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
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
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: rewrite without querystring
I'm not sure you're working on the right rule.
This rule you provided checks of the requested URI is, in fact, REAL!
The condition that would check if he file doesn't exist is
So in your case the rule should look like:
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
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
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 15 guests