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 http://www.yahoo.com/
Order deny,allow
Deny from all
Allow from [Your IP Address - i.e 255.255.255.255]

 

#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! (w3.org)

AuthName "Under Development"
AuthUserFile /web/sitename.com/.htpasswd
AuthType basic
Require valid-user
Order deny,allow
Deny from all
Allow from [Your IP Address - i.e 255.255.255.255] w3.org htmlhelp.com googlebot.com
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
SSLRequireSSL
SSLRequire %{HTTP_HOST} eq "yourdomain.com"
ErrorDocument 403 https://yourdomain.com

 

#4 - Set Timezone of the Server (GMT)

SetEnv TZ Asia/Kolkata

 

#5 - Administrator Email for ErrorDocument

SetEnv SERVER_ADMIN webmaster@yourdomain.com

 

#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

RewriteCond %{REQUEST_METHOD} !^(GET|HEAD|OPTIONS|POST|PUT)
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.