General

Use htaccess to redirect all visitors except your IP address to another website

In this article we explain how you can redirect all web traffic to another website but still be able to access the website from your IP.

Steps to Redirect All Traffic but Exclude Your IP

  1. Edit your .htaccess file
  2. Add the following code to the top of the file.
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REMOTE_HOST} !^10.0.1.1
    RewriteRule .* https://www.example.com [R=302,L]
  3. Change 10.0.1.1 to your public broadband IP address.
  4. Change https://www.example.com to the website url you want to redirect your web traffic to.
  5. Save your .htaccess file changes.

Note; the redirect will take effect immediately

Was this guide helpful?

Need help with this?

Open a ticket and link to this guide so our team can see what you have tried.

View support tickets

Power your business with Ecenica Hosting

Built for WordPress and serious websites. Fast, secure and supported by real people in the UK.

Ecenica hosting services represented by a connected red route across London