For a better experience please change your browser to CHROME, FIREFOX, OPERA or Internet Explorer.

FilesMatch Tag

Like <files> tag that is used to apply conditions to a single file, <FilesMatch> can be used to match to a group of files and apply some conditions to the group of files as below: <FilesMatch “\.(png|jpg)$”> Order Allow, Deny Deny from All </FilesMatch> Read More

Mapping IP Address to Domain Name

Name servers are the servers that convert a specific IP Address to a domain name. This mapping can also be specified in the .htaccess files in the following manner. For Mapping L.M.N.O address to a domain name RewriteCond %{HTTP_HOST} ^L\.M\.N\.O$ [NC] RewriteRule ^(.*)$$1 [L,R=301] The above lines check if the host for any […] Read More

How to Redirect Users to Maintenance Page

n case your website is down for maintenance and you want to notify all your clients that need to access your websites about this then for such cases you can add following lines to your .htaccess websites that allow only admin access and replace the site pages having links to any .jpg, .css, .gif, .js […] Read More

How to Prevent Image Hotlinking for your Website

Another problem that is major factor of large bandwidth consumption by the websites is the problem of hot links which are links to your websites by other websites for display of images mostly of your website which consumes your bandwidth. This problem is also called as ‘bandwidth theft’. A common observation is when a site […] Read More

Renaming htaccess file

For preventing the .htaccess file from the intruders and other people from viewing those files you can rename that file so that it is not accessed by client’s browser. The line that does this is: AccessFileName htac.cess Read More

Custom redirection

For example, redirect url ‘ ‘ to ‘’. RewriteEngine ON RewriteRule ^[0-9]+)([0-9]+)pq$ ^$1&q=$2 In above lines, $1 represents the first bracket and $2 represents the second bracket. Read More

Redirecting entire website to https

Following lines will help you transfer entire website to https: RewriteEngine ON RewriteCond %{HTTPS} !on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} The above lines enable the re-write engine and then check the value of HTTPS environment variable. If it is on then re-write the entire pages of the website to https. Read More

Redirecting a non-www URL to a www URL

Before starting with the explanation, lets first see the lines that are needed to be added to .htaccess file to enable this feature. RewriteEngine ON RewriteCond %{HTTP_HOST} ^abc\.net$ RewriteRule (.*)$1 [R=301,L] The above lines enable the Rewrite Engine and then in second line check all those URL’s that pertain to host or have the HTTP_HOST environment variable set to “”. For […] Read More

Changing Default charset and language headers

.htaccess files allow you to modify the character set used i.e. ASCII or UNICODE, UTF-8 etc. for your website along with the default language used for the display of content. Following server’s global environment variables allow you to achieve above feature. AddDefaultCharset UTF-8 DefaultLanguage en-US Re-writing URL’s: Redirection Rules Re-writing feature simply means replacing the long and un-rememberable URL’s with short and […] Read More

How to Prevent website Directory Listing

To prevent any client being able to list the directories of the website on the server at his local machine add following lines to the file inside the directory you don’t want to get listed. Options -Indexes Read More