logo
Published on Conunity (http://www.conunity.com)

Basic htaccess file

By sysman
Created 2007-07-04 16:18

Description

A very simple htaccess file that demonstrates some of the options available for htaccess.

Configuration file

Download file [1]

Options [1] +ExecCGI -Indexes
DirectoryIndex [1] index.html index.htm index.php

ServerSignature [1] Off
DefaultLanguage [1] en-US
AddDefaultCharset [1] UTF-8

AddType [1] image/x-icon .ico

# Error Documents
ErrorDocument [1] 404 /error404.html
ErrorDocument [1] 400 /error400.html
ErrorDocument [1] 401 /error401.html
ErrorDocument [1] 403 "Forbidden!"
ErrorDocument [1] 405 /error405.html
ErrorDocument [1] 406 /error406.html
ErrorDocument [1] 409 /error409.html
ErrorDocument [1] 500 /error500.html

#AddHandler [1] cgi-script [1] .cgi

#Redirects
RewriteEngine [1] On
RewriteBase [1] /

#Treat Hotlinks
RewriteCond [1] %{HTTP_REFERER} !^$
RewriteCond [1] %{HTTP_REFERER} !^http://(subdomain\.)?domain.com/.*$ [NC]
RewriteRule [1] ^.*\.(bmp|gif|jpg|jpeg|jpe|png)$ - [F]

#Deny [1] bad request methods
RewriteCond [1] %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS [1]|HEAD)$ [NC]
RewriteRule [1] ^.*$ - [F]

#Basic Authentication
AuthType [1] basic
AuthName [1] "Please enter username and password"
AuthUserFile [1] /.htpasswd
Require [1] valid-user [1]

Vote Result
+++++++++-
Score: 9.0, Votes: 2

Source URL:
http://www.conunity.com/basic_htaccess_file