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: Redirect based on query string
Author
Message |
Russell124
Newbie


Joined: 09 November 2011
Posts: 3
Posted: 09 November 2011 at 9:14am

RewriteCond %HTTPS off 
RewriteCond Host: (.*) 
RewriteRule (.*) https\://$1$2 [I,RP]

The above rule redirects everything to https which is good but I want to prevent requests with a certain query string from being redirected.

Example:

http://mydomain.com/servlet/pageViewer?excelReport=true&val1=a&val2=b

When the query string contains "excelReport=true" I don't want the request redirected to https.  I have serached the forum and found some examples but none work for my purpose.

Thanks...

Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 10 November 2011 at 4:09am

Please try using the following set of rules:

RewriteCond %HTTPS off
RewriteCond Host: (.*)
RewriteRule (.*)\?(?!.*excelReport=true.*)(.*) https\://$1$2\?$3 [I,RP]

__________________
Regards,
Anton
Back to Top
 
Russell124
Newbie


Joined: 09 November 2011
Posts: 3
Posted: 10 November 2011 at 7:21am

Anton, thanks for the help. 

It almost works.  The syntax you provided is only redirecting requests that contain "excelReport=true".  I want the oposite to happen.  I only want requests that do not contain "excelReport=true" to be redirected.

Back to Top
 
Russell124
Newbie


Joined: 09 November 2011
Posts: 3
Posted: 10 November 2011 at 7:56am

Anton, disregard my last post.  Your syntax is working as intended.  My testing was flawed.

Thanks again for your help....
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