B
B
Bogdan Gadzhega2015-10-31 17:12:53
Computer networks
Bogdan Gadzhega, 2015-10-31 17:12:53

How to make a redirect on a site, but with an exception for some IP addresses?

Hello.
You need to make a redirect on the site, but with an exception for some IP addresses, namely the IP of the Vkontakte site, so that users have a redirect when they click on the link, but the VK robot checking the site does not.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nirvimel, 2015-10-31
@kalne

The redirect is generally implemented through the web server configs or through a script (php, for example).
For Apache and Nginx, conditional redirects are easy to write. Also on php in the code you can easily check any conditions.
Indicate which option you are interested in, then it will be possible to answer in more detail.
For example, for Apache, you can build something like this:

RewriteEngine On
RewriteCond %{REMOTE_HOST} !^12\.345\.678\.90
RewriteRule $ / [R=302,L]

An example of a conditional redirect in php:
if ($_SERVER['REMOTE_ADDR'] == "some.bot.ip") {
   header("Location: http://example.com/go_out_of_here");
   die();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question