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 (Forum Locked Forum Locked)
 Helicon Tech : ISAPI_Rewrite 2.x
Subject Topic: help with rewrite rule
Author
Message |
HeliconV2_user
Newbie


Joined: 18 May 2011
Location: United States
Posts: 5
Posted: 19 May 2011 at 9:10am

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/([[email protected]_]{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/?
@[email protected]_TEXTDESCRIPTIONEN
http://xyz.gov/Corda/redirector.corda/?
@[email protected]_TEXTDESCRIPTIONEN
http://xyz.gov/Corda/redirector.corda/?
@[email protected]_TEXTDESCRIPTIONEN
http://www.xyz.gov/Corda/redirector.corda/?
@[email protected]_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/?
@[email protected]_TEXTDESCRIPTIONEN" should be
redirected)

regular expression for matching the "corda/?
@[email protected]_TEXTDESCRIPTIONEN" is "([[email protected]_]{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
 
HeliconV2_user
Newbie


Joined: 18 May 2011
Location: United States
Posts: 5
Posted: 19 May 2011 at 11:03am

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/([[email protected]_]{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
 
Lexey
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Posts: 8119
Posted: 21 May 2011 at 5:30am

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

RewriteCond Host: (.*)
RewriteRule .*/Corda/redirector\.corda/\[email protected]_[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
 
HeliconV2_user
Newbie


Joined: 18 May 2011
Location: United States
Posts: 5
Posted: 23 May 2011 at 12:09pm

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/\[email protected]_[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
 
HeliconV2_user
Newbie


Joined: 18 May 2011
Location: United States
Posts: 5
Posted: 24 May 2011 at 2:48pm

Hey Lexey, any idea?
Back to Top
 
Lexey
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Posts: 8119
Posted: 25 May 2011 at 4:12am

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
 
HeliconV2_user
Newbie


Joined: 18 May 2011
Location: United States
Posts: 5
Posted: 26 May 2011 at 12:39pm

Hey Lexey,

Thanks !

one last question, i want a rewrite rule when matches
this format .*/Corda/redirector.corda/\[email protected]_[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/\[email protected]_[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
 
Lexey
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Posts: 8119
Posted: 27 May 2011 at 4:08am

The following pair of rules will do the job:

RewriteRule .*/Corda/redirector\.corda/\[email protected]_[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
 

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

Printable version Printable version
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