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, need to redirect based on host
Author
Message |
stevebombedout
Newbie


Joined: 03 August 2010
Location: United Kingdom
Posts: 4
Posted: 03 August 2010 at 8:01am

What I want to do is allow for an httpd.ini that's flexible enough to work on a number of environments but which, when live, forces any old domains to redirect to our new domain.

This is where I am but it doesn't seem to be working:

RewriteCond %HTTPS off
RewriteCond Host: (!^localhost*)(.+)
RewriteCond Host: (!^stg*)(.+)
RewriteCond Host: (!^www.bombedout.com)(.+) [NC]
RewriteRule /(.*) http\://www.bombedout.com/$1 [I,RP]

I'm basically saying is... If the host IS NOT localhost (eg. localhost 5050) and is not a stg server (e.g. stg-1.bombedout.com) and it's not our current domain either then please redirect to bombedout.com. Otherwise I don't want the redirect to fire.

If I can get this working I'll be able to use the same ini on all environments. Obviously when it's not working any request to, say, stg-2.bombedout.com will simply forward to the live site rather than the staging one.

I hope this makes sense.

Any help appreciated! I've been banging my head against a brick wall for days on this.

Cheers,
Steve.
Back to Top Visit stevebombedout's Homepage
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 03 August 2010 at 8:16am

Please try to use the following config:

RewriteCond %HTTPS off
RewriteCond Host: (?!.*(?:localhost|stg|www\.bombedout\.com).*)(.+)
RewriteRule (.*) http\://www.bombedout.com$1 [I,RP]

__________________
Regards,
Anton
Back to Top
 
stevebombedout
Newbie


Joined: 03 August 2010
Location: United Kingdom
Posts: 4
Posted: 03 August 2010 at 8:28am

Thanks for the quick reply!

This *almost* works. However, if I go to, say, www.oldtesturl.com this is now redirecting to http://www.bombedout.comwww.oldtesturl.com rather than straight to http://www.bombedout.com.

Thanks!
Back to Top Visit stevebombedout's Homepage
 
stevebombedout
Newbie


Joined: 03 August 2010
Location: United Kingdom
Posts: 4
Posted: 03 August 2010 at 8:31am

Aha - replacing $1 with $2 on the last line looks like it's fixed that. #

Brilliant! Thanks a million!

Back to Top Visit stevebombedout's Homepage
 

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