Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 3.0
 Helicon Tech : ISAPI_Rewrite 3.0
Subject Topic: RewriteMap and RewriteRule and querystrin Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
cameron_ca
Newbie
Newbie


Joined: 25 June 2010
Location: United States
Online Status: Offline
Posts: 2
Posted: 25 June 2010 at 4:50pm | IP Logged Quote cameron_ca

I've got a map file that looks like this:

index.php?id=100 /newpage1
oldpage.htm?site=a /newpage2
contact.php /newpage3

The rule in use is:
RewriteMap redirects301 txt:d:/WEBROOT/config/redirects301.txt [NC]
RewriteCond ${redirects301:$1|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule ^(.+)$ ${redirects301:$1} [NC,L,R=301]

On this site I have access to the httpd.conf file and the customer has access to the redirects301.txt file. My goal is
for the end user to be able to set their own redirects without needing access to the primary config file. This works
fine... almost. The problem is whenever the URL contains a querystring; the redirect doesn't happen. I'm familiar
with the use of RewriteCond %{QUERY_STRING} when you know what the querystring might contain ahead of time, but in this
case all I know is contained in What I really want to do is just completely ignore the ? and treat it as one entire
URL.

Any ideas?
Back to Top View cameron_ca's Profile Search for other posts by cameron_ca
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10483
Posted: 29 June 2010 at 5:53am | IP Logged Quote Anton

Please try to fix your config like this:

RewriteMap redirects301 txt:d:/WEBROOT/config/redirects301.txt [NC]
RewriteCond %{QUERY_STRING} ^(.+)?$
RewriteCond ${redirects301:$1(?%1\?%1)|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule ^(.+)$ ${redirects301:$1(?%1\?%1)}? [NC,L,R=301]

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
dooza
Newbie
Newbie


Joined: 06 April 2009
Location: United Kingdom
Online Status: Offline
Posts: 32
Posted: 08 July 2010 at 5:16am | IP Logged Quote dooza

This is exactly what I was looking for, you have saved me hours of work, thank you very much!

Dooza
Back to Top View dooza's Profile Search for other posts by dooza
 
cameron_ca
Newbie
Newbie


Joined: 25 June 2010
Location: United States
Online Status: Offline
Posts: 2
Posted: 08 July 2010 at 8:02am | IP Logged Quote cameron_ca

Yep, worked for me too!
Back to Top View cameron_ca's Profile Search for other posts by cameron_ca
 
TonyJ
Newbie
Newbie


Joined: 29 July 2010
Location: Belgium
Online Status: Offline
Posts: 1
Posted: 29 July 2010 at 11:19am | IP Logged Quote TonyJ

Anton wrote:
Please try to fix your config like this:

RewriteMap redirects301 txt:d:/WEBROOT/config/redirects301.txt [NC]
RewriteCond %{QUERY_STRING} ^(.+)?$
RewriteCond ${redirects301:$1(?%1\?%1)|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule ^(.+)$ ${redirects301:$1(?%1\?%1)}? [NC,L,R=301]


Thanks Anton for sharing with us your solution.
I tested your solution and it worked for me too but not for "dir1/dir2/?Test=100" !

Small question how do I need to change it for it also to work with

dir1/dir2/?Test=100 /newdir1/filename100
dir3/?T=UK /newdir3/filename2

In other words what if QUERY_STRING is directly preceded by a / how do we need to change ReWriteCond ?

Thanks already for your input

Tony


Edited by TonyJ - 29 July 2010 at 11:21am


__________________
Tony J
Creations.be
Back to Top View TonyJ's Profile Search for other posts by TonyJ Visit TonyJ's Homepage
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10483
Posted: 30 July 2010 at 3:52am | IP Logged Quote Anton

Please try to fix it like this:

RewriteMap redirects301 txt:d:/WEBROOT/config/redirects301.txt [NC]
RewriteCond %{QUERY_STRING} ^(.+)?$
RewriteCond ${redirects301:$1(?%1\?%1)|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule ^(.+?)/?$ ${redirects301:$1(?%1\?%1)}? [NC,L,R=301]

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You can vote in polls in this forum