×

Archive

How to Redirect all Visitors Except One IP to Another Website

Sometimes you may need to redirect all web traffic to another website or another page within your site but you still want to be able to view your website. This is common when you are making changes that you are not ready for others to see just yet or when you are performing maintenance. In this article, we will discuss How to Redirect all Visitors Except One IP to Another Website.

In this Article:  Take me to the .htaccess Code

 

You can achieve this in a few simple steps using the .htaccess file which is located in the document root of your website. To edit your .htaccess file, you will need to access File Manager in your cPanel account.

 

How to Redirect all Visitors Except One IP to Another Website

Edit Your .htaccess file via File Manager:

 

1. Log into cPanel

2. Click on ‘File Manager

3. Navigate to the document root for your website.

4. Locate the ‘.htaccess‘ file in the list. Click once on the file to highlight it, then right click on the file and select ‘edit‘.How to Redirect all Visitors Except One IP to Another Website

Click on ‘Edit‘ again in the prompt to open the file for editing.

How to Redirect all Visitors Except One IP to Another Website

Note! .htaccess is considered a dot file. In File Manager, dot files are hidden by default. You will need to “unhide” them in the settings in file manager to see your .htaccess file.

→ Click Here to Learn How to Show Hidden (dot) files in File Manager

 

5. With the .htaccess file open in the editor, paste the following code into the next line in the file:

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^1.2.3.4
RewriteRule .* http://www.newwebsiteurl.com [R=302,L]

In the code above:

 

Example:

How to Redirect all Visitors Except One IP to Another Website

 

6. Click ‘Save‘ to save your changes!

That’s it! You should be able to browse to your website from your IP address but all other visitors should be redirected to the URL you specify.

 

How to Show Hidden (dot) files in File Manager

Sometimes you may need to make changes to files such as ‘.htaccess‘ in File Manager in your cPanel account. If this is your first time accessing File Manager, you may notice that you cannot see these files! This is because dot files are hidden by default in File Manager. So, How do you View Hidden (dot) Files in File Manager? Great question! In this Article we will discuss How to Show Hidden (dot) files in File Manager in a few simple steps.

 

Note! You should only perform this action if you are comfortable editing Files in File Manager as improper modification of these files can have undesirable effects. Though, it is safe to view these files if you simply want to view them. To view Hidden (dot) files in File Manager, follow the steps outlined below:

 

How to Show Hidden (dot) files in File Manager

1. Log in to cPanel

2. Click on ‘File ManagercPanel File Manager

3. Click on ‘Settings‘ in the top right hand cornercPanel File Manager Settings

4. Select the Box for ‘Show Hidden Files (dotfiles)How to Show Hidden (dot) Files in File Manager

5. Click ‘Save‘!

 

That’s it! You should now be able to view all hidden (dot) files on the file server in your account! You can follow these steps again and uncheck the box ‘Show Hidden (dot) files’ to reverse the changes.