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.
Thread Tools Display Modes
Old 29th November 2012, 00: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 BUT NOT
Redirect to http://this.site

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?

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

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

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


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 10:33
How to create a subdomain that doesn't change the url but still goes to redirect path todx General 3 21st April 2012 19:32
New feature request: Frame redirect funtion for ISPConfig3 Hans Feature Requests 1 12th January 2011 01:43
Webmail URL redirect to /mail lewis_saint General 0 7th November 2010 22:01
Two hosters - redirect url from one to the other vistree Server Operation 3 7th June 2010 14:44

All times are GMT +2. The time now is 23:56.

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