This article is for cPanel Accounts. Determine where your account is with this guide.
Find original information at: http://www.thejackol.com/htaccess-cheatsheet/
Options +Indexes
## Block a few types of files from showing
IndexIgnore *.wmv *.mp4 *.avi
Options All -Indexes
ErrorDocument 403 /forbidden.html
ErrorDocument 404 /notfound.html
ErrorDocument 500 /servererror.html
AddType text/html .html
AddType text/html .shtml
AddHandler server-parsed .html
AddHandler server-parsed .shtml
# AddHandler server-parsed .htm
DirectoryIndex myhome.htm index.htm index.php
order deny, allow
deny from 202.54.122.33
deny from 8.70.44.53
deny from .spammers.com
allow from all
to order deny, allow
deny from all
allow from 192.168.0.0/24
Redirect oldpage.html http://www.domainname.com/newpage.html
Redirect /older http://www.domainname.com/newdir/
RewriteEngine on
RewriteCond %{HTTP_REFERER} site-to-block\.com [NC]
RewriteCond %{HTTP_REFERER} site-to-block-2\.com [NC]
RewriteRule .* - [F]
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ - [F]
Add this below the Hot Link Blocking code:
RewriteRule \.(gif|jpg)$ http://www.mydomain.com/dontsteal.gif [R,L]
order allow, deny
deny from all
# Avoid 500 error by passing charset
AddDefaultCharset utf-8
Options +ExecCGI
AddHandler cgi-script cgi pl
# To enable all scripts in a directory use the following
# SetHandler CGI-script
Use the .htaccess Password Generator and follow the brief instructions!
AddType application/x-httpd-php .gne
gene
will now be treated as PHP files! Similarly, x-httpd-cgi
for CGI files, etc.
Performance may take a hit but if that's not a problem, this is a nice option to turn on.
ContentDigest On
From Jens Meiert: CheckSpelling corrects simple spelling errors (for example, if someone forgets a letter or if any character is just wrong). Just add CheckSpelling On
to your htaccess file.
As the Apache core features documentation says: “This directive enables the generation of Content-MD5 headers as defined in RFC1864 respectively RFC2068. The Content-MD5 header provides an end-to-end message integrity check (MIC) of the entity body. A proxy or client may check this header for detecting accidental modification of the entity-body in transit.
Note that this can cause performance problems on your server since the message digest is computed on every request (the values are not cached). Content-MD5 is only sent for documents served by the core, and not by any module. For example, SSI documents, output from CGI scripts, and byte range responses do not have this header.”
To turn this on, just add ContentDigest On
.
# BEGIN GZIP
# Combine the below two lines - I've split it up for presentation
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css
application/x-javascript application/javascript
# END GZIP
Turn off magic_quotes_gpc
# Only if you use PHP
php_flag magic_quotes_gpc off
ExpiresActive On ExpiresDefault "access plus 1 second" ExpiresByType text/html "access plus 7200 seconds" ExpiresByType image/gif "access plus 518400 seconds" ExpiresByType image/jpeg "access plus 518400 seconds" ExpiresByType image/png "access plus 518400 seconds" ExpiresByType text/css "access plus 518400 seconds" ExpiresByType text/javascript "access plus 216000 seconds" ExpiresByType application/x-javascript "access plus 216000 seconds"
# Cache specified files for 6 days Header set Cache-Control "max-age=518400, public" # Cache HTML files for a couple of hours Header set Cache-Control "max-age=7200, private, must-revalidate" # Cache PDFs for a day Header set Cache-Control "max-age=86400, public" # Cache Javascript for 2.5 days Header set Cache-Control "max-age=216000, private"
No worries, Our experts are here to help.