Skip to content

Instantly share code, notes, and snippets.

@1stevengrant
Created November 19, 2012 02:17
Show Gist options
  • Save 1stevengrant/4108610 to your computer and use it in GitHub Desktop.
Save 1stevengrant/4108610 to your computer and use it in GitHub Desktop.
This htaccess file redirects users who don't have the designated IP address to another url. I needed this because the we didn't want the clients new url to be accessed by anyone else in production until the official go live. You can allow access for multi
RewriteEngine on
# If your IP address matches any of these - then dont re-write
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1
RewriteRule ^(.*)$ http://www.anothersite.com/ [R=302,L]
# do not rewrite links to the assets and theme files
RewriteCond $1 !^(assets|themes|images)
# do not rewrite for php files in the document root, robots.txt etc
RewriteCond $1 !^([^\..]+\.php|robots\.txt|crossdomain\.xml)
# but rewrite everything else
RewriteRule ^(.*)$ index.php/$1 [L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment