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


Joined: 17 June 2010
Location: United States
Online Status: Offline
Posts: 2
Posted: 17 June 2010 at 1:04pm | IP Logged Quote DavidsonHC

 

Hi, I need some help with constructing RewriteRule regular expression, here is my problem:

 I have a site hosted as http://www.mysite.com  and any incoming requests to this URL must redirect
 to a new site http://www.mynewsite.com.  However if the incoming request has path or query attached
 to it rewrite should not happen, here are few examples:
 
   http://www.mysite.com   redirects to>>   http://www.mynewsite.com
   https://www.mysite.com  redirects to>>   https://www.mynewsite.com
   http://www.mysite.com/  redirects to>>   http://www.mynewsite.com
   http://www.mysite.com/# redirects to>>   http://www.mynewsite.com
  
   http://www.mysite.com/?    should not redirect
   http://www.mysite.com/directory  should not redirect
   http://www.mysite.com/?param     should not redirect
  
 to make this work I have tried rewrite statement:
 
   RewriteRule (http|https)://www.mysite.com(/|/#)? http\://www.mynewsite.com [I,R]
  
 this does not work, what am I doing wrong? On the Regular Expression Test Utility this seems to be working.

Back to Top View DavidsonHC's Profile Search for other posts by DavidsonHC
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10489
Posted: 18 June 2010 at 2:59am | IP Logged Quote Anton

Here's the correct config for ISAPI_Rewrite v2:

[ISAPI_Rewrite]
RewriteCond %HTTPS .*(on)?.*
RewriteCond Host: www\.mysite\.com
RewriteRule (?:/|/#)? http(?1s)\://www.mynewsite.com [I,RP]

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


Joined: 17 June 2010
Location: United States
Online Status: Offline
Posts: 2
Posted: 22 June 2010 at 12:33pm | IP Logged Quote DavidsonHC

Thank you Anton, it works.

I ended up omitting the HTTPS server variable check portion.

Back to Top View DavidsonHC's Profile Search for other posts by DavidsonHC
 

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