Apache Only allow certain IP's and redirect others
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Location: /home/chenxiaolong and /root and /Users/chenxiaolong and C:\Users\chenxiaolong
Distribution: Fedora 12, Debian 5, Ubuntu 10.04
Posts: 17
Rep:
Apache Only allow certain IP's and redirect others
I'm using Apache 2 on a Linux server and I was wondering if it was possible to redirect certain IP ranges to another page. I know it's possible to block an IP, but is there a way to block all IP's and only allow a certain IP range to connect, such as 5.87.xxx.xxx? I own this server, so if I need to use another OS, webserver, change configuration files, etc., that's fine.
or you can reroute through your firewall (depending on OS, IPtables e.g, to a virtual network device (bonded adapter confg e.g. eth1:1)
and in the apache conf, set the site for that device to respond to.
NameVirtualHost the.ip.address.here:80 (subsitute the.ip.address.here with the real ip)
in apache, and then the rest of the config added to it.
Location: /home/chenxiaolong and /root and /Users/chenxiaolong and C:\Users\chenxiaolong
Distribution: Fedora 12, Debian 5, Ubuntu 10.04
Posts: 17
Original Poster
Rep:
How would I do that? The computers within 5.87.*.* should be able to access the index page and all other people get redirected to http://domain.com/alternatesite. I don't want them to be blocked, just redirects. I can't change the 403 error page also because I don't want inaccessible directory listings to be redirected.
By the way, I use Debian and CentOS on my servers, so if I need to install anything, RPM and DEB are okay.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.