M
M
Maxim Lesnikov2014-06-06 10:58:51
htaccess
Maxim Lesnikov, 2014-06-06 10:58:51

Redirecting certain IP addresses to different sites?

Good day to all. Faced such a problem.
There is a main domain:
http://site.ru
and there are 4 subdomains in this domain.
There is a list of IP addresses with subnets.
It is necessary to make a redirect to subdomains for certain IPs. Example:
10.76.0.0/14
10.80.0.0/14
go automatically to subdomain 1.sayt.ru
10.64.0.0/14
10.240.0.0/17
go to subdomain 2.sayt.ru
And so on.
Any suggestions on this issue?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Lesnikov, 2014-06-06
@maximka_l

I found the following solution:
if ($_SERVER['REMOTE_ADDR'] == "1.1.1.1") {
header("Location: ya.ru ");
}
Everything works great. But if you make a subnet for example 1.1.1.1/24 - it doesn't work :(

V
Vlad Zhivotnev, 2014-06-06
@inkvizitor68sl

In nginx, use the $geo block.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question