Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 28th November 2012, 23:37
forrie forrie is offline
Junior Member
 
Join Date: Sep 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Redirect all except one /24 to another URL

I'm having a devil of a time getting Apache's Rewrite* stuff to do what I need.

Basically, I have a range of IP space that I need to redirect to a specific URL /except/ one IP within that range. Everyone else in the world also gets the normal/default URL.

So, in pseudocode:

If matches all of 1.2.0.0 BUT NOT 1.2.3.4
Redirect to http://this.site
else
continue
Fi

Specifically I am also redirecting any queries to ^/ to a specific page (ie: index.php) but I need the above conditional to apply.

I've tried many examples from out there and it's understandably confusing. It appears you can't really negate this in a RewriteCond loop, either -- I tried it.

Anyone know how to accomplish this correctly in apache 2.2?


Thanks.
Reply With Quote
Sponsored Links
  #2  
Old 5th December 2012, 22:09
patrick3853 patrick3853 is offline
Member
 
Join Date: Dec 2008
Posts: 30
Thanks: 3
Thanked 7 Times in 3 Posts
 
Default

By default multiple RewriteCond's are treated using a logical AND, so...

Code:
RewriteCond %{REMOTE_ADDR} ^1\.2\.
RewriteCond %{REMOTE_ADDR} !^1\.2\.3\.4$
RewriteRule...
Does exactly what you want. It says If the IP starts with 1.2. and does not equal 1.2.3.4, then apply the rule
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ISPConfig 3 - redirect url automatically adds index.html Chadley General 2 27th November 2013 09:33
How to create a subdomain that doesn't change the url but still goes to redirect path todx General 3 21st April 2012 18:32
New feature request: Frame redirect funtion for ISPConfig3 Hans Feature Requests 1 12th January 2011 00:43
Webmail URL redirect to /mail lewis_saint General 0 7th November 2010 21:01
Two hosters - redirect url from one to the other vistree Server Operation 3 7th June 2010 13:44


All times are GMT +2. The time now is 18:54.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.