This forum has been moved here:
Helicon Tech Community Forum

ISAPI_Rewrite 3.0 (Forum Locked Forum Locked)
 Helicon Tech : ISAPI_Rewrite 3.0
Subject Topic: Help in writing a rule with RewriteCond
Author
Message |
websupport
Newbie


Joined: 06 January 2012
Posts: 2
Posted: 06 January 2012 at 8:52am

Hi Support,

We are using ISAPI Rewrite 3 on one of our servers. We
have a requirement to check if one of the querystring
parameter�s value in a URL contains space. We need to
perform a redirect based on it.

For e.g. Following URLs should be redirected to different
URLs.
1. �http://www.mydomain.com/t1/t2/?QP=test�
2. �http://www.mydomain.com/t1/t2/?QP=test with space�

We have written the following rule to redirect, if the
Querystring value does not contain a space.

RewriteCond $4 ^QP=([a-zA-Z0-9_-]+)
RewriteRule ^t1/t2/ ?(.*?)?(?:\?(.*))?$ /t3/t4 [NC,L]

The above rule should redirect only the URL1 and not
URL2. However, this rule redirects both URLs mentioned in
my example.

Can you please help us in framing the pattern match for
the RewriteCond?

Thanks!!
Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 10 January 2012 at 4:41am

hello,

The issue is that querystring parameter needs to have its separate condition:

RewriteCond %{QUERY_STRING} ^QP=([a-zA-Z0-9_-]+)$
RewriteRule ^t1/t2/$ /t3/t4 [NC,L]

Regards
Andrew
Back to Top
 
websupport
Newbie


Joined: 06 January 2012
Posts: 2
Posted: 10 January 2012 at 2:45pm

Hello Andrew,

Thanks for your reply..!! The above helped  me resolving another issue
For the current issue I have framed my question incorrectly.Sorry for that.

So here is our requirement that we want to achieve.
If the $4 in the rewrite condition below has a space in it then I need to redirect to the rewrite rule below.

RewriteCond $4 <Something which I Need from you>
RewriteRule ^(alpha)/([a-zA-Z0-9_-]+)/?(.*?)?(?:\?(.*))?$ /beta/gamma/$4?docid=$1&locid=$2&pid=$3 [NC,L]

NOTE: $4 can have any character EXCEPT space...

Thanks!!


Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 12 January 2012 at 4:06am

Try using:

Code:
RewriteCond $4 (\S+)
RewriteRule ^(alpha)/([a-zA-Z0-9_-]+)/?(.*?)?(?:\?(.*))?$ /beta/gamma/$4?docid=$1&locid=$2&pid=$3 [NC,L]


Regards
Andrew
Back to Top
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version