Here are some specific examples to use in your .htaccess file. This can help you to improvise your website functioning, and also helps to boost speed


#1 - Redirect Everyone Except IP address to an alternate page

ErrorDocument 403
Order deny,allow
Deny from all
Allow from [Your IP Address - i.e]


#2 -  When developing sites

This lets google crawl the page, lets me access without a password, and lets my client access the page WITH a password. It also allows for XHTML and CSS validation! (

AuthName "Under Development"
AuthUserFile /web/
AuthType basic
Require valid-user
Order deny,allow
Deny from all
Allow from [Your IP Address - i.e]
Satisfy Any


#3- Fix double-login prompt

Redirect non-https requests to https server and ensure that .htpasswd authorization can only be entered across HTTPS

SSLOptions +StrictRequire
SSLRequire %{HTTP_HOST} eq ""
ErrorDocument 403


#4 - Set Timezone of the Server (GMT)

SetEnv TZ Asia/Kolkata


#5 - Administrator Email for ErrorDocument



#6 - ServerSignature for ErrorDocument

ServerSignature off | on | email


#7 - Charset and Language headers

AddDefaultCharset UTF-8
DefaultLanguage en-US


#8 - Disallow Script Execution

Options -ExecCGI
AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi


#9 - Deny Request Methods

RewriteRule .? - [F]


#10 - Force "File Save As" Prompt

AddType application/octet-stream .avi .mpg .mov .pdf .xls .mp4




That's it for now, We will cover more snippets for .htaccess file in further parts. You can write to us in the comment section below if you have any query. We will certainly like to help you.