Home / Web servers / How to redirect a specific IP address

How to redirect a specific IP address

Custom 403 forbidden error page
Question: How do I redirect every visitor to my website except for me?

Answer: There are two methods you can use to accompany the results you want and both involve using an .htaccess file. The first is to redirect your site’s visitors with standard Apache directives:

ErrorDocument 403 http://www.yourdomain.com
Order deny,allow
Deny from all
Allow from 192.168.5.5

This will redirect anyone who visits the site to yourdomain.com, with the exception of your computer or whichever computer uses the stated IP address.

Alternatively, you may use mod_rewrite to achieve similar results:

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^192\.168\.5\.5
RewriteCond %{REQUEST_URI} !/temporary-offline\.html$
RewriteRule .* /temporary-offline.html [R=302,L]

Photo Source: Flickr

Check Also

Uk data center

Professional Data Centres In The UK

A professional data centre is a location in which various pieces of hardware are located …

Powered by Namesco
© Copyright InternetBlog.Org.Uk 2024, All Rights Reserved