IP redirects in .htaccess
So you've set up your development environment, you have a test server and a production server. You want to restrict access to the test server, so that only your development team, your client and perhaps the designer can actually view the test server. The rest of the world should always be presented with the production environment. Well, there's a simple piece of code you can enter in your .htaccess file in your Drupal root on the test server:
# Only allow access for certain ip-addresses
RewriteCond %{REMOTE_ADDR} !^1\.1\.1\.1
RewriteCond %{REMOTE_ADDR} !^2\.2\.2\.2
RewriteRule ^(.*)$ http://www.example.com [L,R=301]
This piece of code will redirect any visitor to the URL of your choice, except those with the given ip-addresses. If you put this right below the part where it says RewriteEngine on in your Drupal .htaccess file, it should work. Do not forget to write the ip-addresses with the \ before the .'s. A point is a character with special meaning and using the \ will negate the special meaning, making it an actual point.

Reactie toevoegen