You can speed up the site by enabling file caching General Format <FilesMatch “.(Extenstion of the file to be cached)$”> Header set Cache-Control “max-age=cache time″ </FilesMatch> Example <FilesMatch “.(html|htm)$”> Header set Cache-Control “max-age=43200″ </FilesMatch
All posts by Pramod T P
Protect your site from hotlinking
You can protect your site from hotlinking by adding the below given code in your htaccess file .
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://([ -a-z0-9] .)?domain.com [NC]
RewriteRule .(gif|jpe?g|png)$ – [F,NC,L]
Hotlinking
Hotlinking (also known as Inline linking, leeching, piggy-backing, direct linking, offsite image grabs, bandwidth theft) is the use of a linked object, often an image, from one site by a web page belonging to a second site. The second site is said to have an inline link to the site where the object is located.
Redirect to a secure https connection
Add the below given code in your htaccess page to redirect to https connection
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Restrict maximum execution time – .htaccess
php_value max_execution_time 200
php_value max_input_time 200
Restrict file upload limits using .htaccess code
php_value upload_max_filesize 10M
php_value post_max_size 10M
Set up a 301 redirect
If you rename the url of a page and need to redirect old URL to your new page, use the below given code in your htaccess page
Redirect 301 old_file_name.html http://example.com/new/file_name.html
Set the default page of each directory
You can set any page as a default page in a directory by adding below given code in your .htaccess file
DirectoryIndex firstpage.html
Create a custom error page
You can create custom error pages and redirect to these pages by adding the below given codes in the htaccess pages
ErrorDocument 404 /404.php
ErrorDocument 500 /500.php
ErrorDocument 401 /401.php
ErrorDocument 403 /403.php
Prevent directory browsing
If index file is not there in a directory, visitors can view all the files in that directory.
You can prevent this by adding a single line code (Given Below)in your .htaccess file .
Options All -Indexes