This forum has been moved here:
Helicon Tech Community Forum

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 2.x
 Helicon Tech : ISAPI_Rewrite 2.x
Subject Topic: help with rewrite rule Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
HeliconV2_user
Newbie
Newbie


Joined: 18 May 2011
Location: United States
Online Status: Offline
Posts: 5
Posted: 19 May 2011 at 9:10am | IP Logged Quote HeliconV2_user

Hi,

is there a way we can write an if/else condition rules??
below are the details what i am trying

RewriteCond Host: (.*)
RewriteRule .*/Corda/redirector.corda/([?@_]{3}[a-zA-Z0-
9]{5}[_][a-zA-Z0-9]{4}[_][a-zA-Z0-9]{4}[@_]{2}[A-Z]{17})?
http://$1/search.aspx [I,RP,U,L]

this rule works fine for all the url's mentioned below as
it satisfies the reg ex.


http://xyz.gov/Corda/redirector.corda/?
@_CPRIH_raPH_MOHK@_TEXTDESCRIPTIONEN
http://xyz.gov/Corda/redirector.corda/?
@_CPRMR_raPM_HNVX@_TEXTDESCRIPTIONEN
http://xyz.gov/Corda/redirector.corda/?
@_CPRSI_raPQ_d27v@_TEXTDESCRIPTIONEN
http://www.xyz.gov/Corda/redirector.corda/?
@_CPRHO_raRF_xyef@_TEXTDESCRIPTIONEN

if the url is not in that format , i need to redirect the
request to an error page.(in other words, any request
that does not match this format "corda/?
@_CPRIH_raPH_MOHK@_TEXTDESCRIPTIONEN" should be
redirected)

regular expression for matching the "corda/?
@_CPRIH_raPH_MOHK@_TEXTDESCRIPTIONEN" is "([?@_]{3}[a-zA-
Z0-9]{5}[_][a-zA-Z0-9]{4}[_][a-zA-Z0-9]{4}[@_]{2}[A-Z]
{17})"

any help would be greatly appriciated.
Back to Top View HeliconV2_user's Profile Search for other posts by HeliconV2_user
 
HeliconV2_user
Newbie
Newbie


Joined: 18 May 2011
Location: United States
Online Status: Offline
Posts: 5
Posted: 19 May 2011 at 11:03am | IP Logged Quote HeliconV2_user

long story short, Can some one provide me a rewrite rule
that will redirect the requests that does not the match the
this pattern ".*/Corda/redirector.corda/([?@_]{3}[a-zA-Z0-
9]{5}[_][a-zA-Z0-9]{4}[_][a-zA-Z0-9]{4}[@_]{2}[A-Z]{17})"

Thanks in Advance!

Back to Top View HeliconV2_user's Profile Search for other posts by HeliconV2_user
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 8119
Posted: 21 May 2011 at 5:30am | IP Logged Quote Lexey

First, your rule is not completely correct.
The correct one is:

RewriteCond Host: (.*)
RewriteRule .*/Corda/redirector\.corda/\?@_[a-zA-Z0-
9]{5}_[a-zA-Z0-9]{4}_[a-zA-Z0-9]{4}@_[A-Z]{17}
http\://$1/search.aspx [I,RP,U]

Second, you could simply put the 2nd rule like:

RewriteCond Host: (.*)
RewriteRule .* http\://$1/error.aspx [RP,U]

after the 1st one. It will redirect anything that has not been matched by the 1st rule.
Back to Top View Lexey's Profile Search for other posts by Lexey
 
HeliconV2_user
Newbie
Newbie


Joined: 18 May 2011
Location: United States
Online Status: Offline
Posts: 5
Posted: 23 May 2011 at 12:09pm | IP Logged Quote HeliconV2_user

Hey Lexey,

Thanks for your response.

i added these two entries in my httpd.ini file as you
mentioned and now every request is redirected to error
page.

do i need to group these 2 rules? not sure if i am
missing anything

RewriteCond Host: (.*)
RewriteRule .*/Corda/redirector.corda/\?@_[a-zA-Z0-9]
{5}_[a-zA-Z0-9]{4}_[a-zA-Z0-9]{4}@_[A-Z]{17}
http://$1/search.aspx [I,RP,U]

RewriteCond Host: (.*)
RewriteRule .* http\://$1/error.aspx [RP,U]
Back to Top View HeliconV2_user's Profile Search for other posts by HeliconV2_user
 
HeliconV2_user
Newbie
Newbie


Joined: 18 May 2011
Location: United States
Online Status: Offline
Posts: 5
Posted: 24 May 2011 at 2:48pm | IP Logged Quote HeliconV2_user

Hey Lexey, any idea?
Back to Top View HeliconV2_user's Profile Search for other posts by HeliconV2_user
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 8119
Posted: 25 May 2011 at 4:12am | IP Logged Quote Lexey

Oh, sorry, that is my fault.

Either replace the the 2nd rule with:

RewriteCond Host: (.*)
RewriteRule (?!/search\.aspx).* http\://$1/error.aspx [RP,U]

or add the following rule before the previous two rules:

RewriteRule /search\.aspx.* $0 [I,L]
Back to Top View Lexey's Profile Search for other posts by Lexey
 
HeliconV2_user
Newbie
Newbie


Joined: 18 May 2011
Location: United States
Online Status: Offline
Posts: 5
Posted: 26 May 2011 at 12:39pm | IP Logged Quote HeliconV2_user

Hey Lexey,

Thanks !

one last question, i want a rewrite rule when matches
this format .*/Corda/redirector.corda/\?@_[a-zA-Z0-9]
{5}_[a-zA-Z0-9]{4}_[a-zA-Z0-9]{4}@_[A-Z]{17} should do
nothing.

i mean ,

RewriteCond Host: (.*)
RewriteRule .*/Corda/redirector.corda/\?@_[a-zA-Z0-9]
{5}_[a-zA-Z0-9]{4}_[a-zA-Z0-9]{4}@_[A-Z]{17}
DO NOTHING [I,RP,U].

in my earlier post i mentioned it wrong, it should not
redirect to serch.aspx when it matches the format.it
should only redirect to error page when it does not match
the format.

sorry about the confuiosn, above solution you provided
worked but even the urls that match the format are being
redirected, which is not the requirement.

our basic requirement is to filter any requests that
does not match the format and redirect to error page , if
it matches then do nothing(let the original request go
thru).


Thanks alot !!
Back to Top View HeliconV2_user's Profile Search for other posts by HeliconV2_user
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 8119
Posted: 27 May 2011 at 4:08am | IP Logged Quote Lexey

The following pair of rules will do the job:

RewriteRule .*/Corda/redirector\.corda/\?@_[a-zA-Z0-9]
{5}_[a-zA-Z0-9]{4}_[a-zA-Z0-9]{4}@_[A-Z]{17} $0 [I,L]

RewriteCond Host: (.*)
RewriteRule .* http\://$1/error.aspx [RP,U]
Back to Top View Lexey's Profile Search for other posts by Lexey
 

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 cannot vote in polls in this forum