Skip to content

Instantly share code, notes, and snippets.

@benhuson
Last active September 9, 2015 15:52
Show Gist options
  • Select an option

  • Save benhuson/9388424 to your computer and use it in GitHub Desktop.

Select an option

Save benhuson/9388424 to your computer and use it in GitHub Desktop.
.htaccess examples
# Redirect to fully qualified domain if different
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example.com
RewriteRule (.*) http://www.example.com%{REQUEST_URI}
</IfModule>
# Only allow specific IPs for testing
<Limit GET POST>
order deny,allow
deny from all
allow from 000.000.000.001
allow from 000.000.000.002
</Limit>
# Deny direct access to files
<Files .htaccess,.svn,debug.log>
order allow,deny
deny from all
</Files>
# Redirect all old file to home ignoring some folders
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/images/
RewriteCond %{REQUEST_URI} !^/css/
RewriteCond %{REQUEST_URI} !^/js/
RewriteRule ^([^/]+)(.*)$ / [R]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment