Skip to content

Instantly share code, notes, and snippets.

@prcaen
Created January 14, 2014 22:04
Show Gist options
  • Save prcaen/8426744 to your computer and use it in GitHub Desktop.
Save prcaen/8426744 to your computer and use it in GitHub Desktop.
Virtualhost configurations
# Restrict access to website and fallback to password.
<Directory "/var/sites/SITE/">
AllowOverride All
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /var/sites/SITE/.htpasswd
Require user
Order allow,deny
Allow from 127.0.0.1
Satisfy Any
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php [QSA,L]
</Directory>
# Redirect mywebsite.com to www.mywebsite.com
<VirtualHost *:80>
ServerName example.com
Redirect permanent / http://www.example.com/
</VirtualHost>
<VirtualHost *:80>
ServerName www.example.com
</VirtualHost>
# No index on files
<Directory "/folder/">
Options All -Indexes
</Directory>
# .htaccess block
<Files .htaccess>
Order allow,deny
deny from all
</Files>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment