What is .htaccess ?

No Comments

.htaccess :

.htaccess is a configuration file for use on web servers running the Apache Web Server software. When a .htaccess file is placed in a directory which is in turn ‘loaded via the Apache Web Server’, then the .htaccess file is detected and executed by the Apache Web Server software. These .htaccess files can be used to alter the configuration of the Apache Web Server software to enable/disable additional functionality and features that the Apache Web Server software has to offer. These facilities include basic redirect functionality, for instance if a 404 file not found error occurs, or for more advanced functions such as content password protection or image hot link prevention.

 
 

What .htaccess file includes ?

    AuthName “Member’s Area Name”
    AuthUserFile /path/to/password/file/.htpasswd
    AuthType Basic
    require valid-user
    ErrorDocument 401 /error_pages/401.html
    AddHandler server-parsed .html

This is a fairly advanced example: it enables password protection on the directory; it offers redirection to a custom error page if a user fails to login correctly; and it enables SSI (server side includes) for use with ‘.html’ files. Please don’t be put off, it’s very simple once you gain a basic understanding and this article provides examples which are ready to go – simply copy, paste and customize.

 

.htaccess is not visible even after uploading?

Dont worry use following steps to unhide .htaccess file :

Note, when you upload your .htaccess file it may not appear in the directory listings for files on your web site. Do not worry; this means your server or FTP software is hiding them which should not be an issue.
A possible cause of error is if the file permissions on the .htaccess file are not set correctly. This only occurs on certain servers, but you may like to change the permissions on the file to ‘755’ or ‘executable’. You can do this with your FTP software, look for a ‘File Permissions’ or ‘CHMOD’ option, and input ‘0755’.

There is another method to view the .htaccess file. When you click on file manager in your cpanel account, select “show hidden files” on popup. This will enable viewing and editing .htaccess file from file manager itself

 

To redirect from http:// to http://www. , and also remove the route file (index.php) in the url, put these lines on your htaccess :


    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
    RewriteCond $1 !^(index\.php|images|css|js|styles|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]

 

To redirect from http://www. to http:// , and also remove the route file (index.php) in the url, put these lines on your htaccess :


    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
    RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

 
 
For more information go on our redirect www to non www blog

About us and this blog

We are a digital marketing company with a focus on helping our customers achieve great results across several key areas.

Request a free quote

We offer professional SEO services that help websites increase their organic search score drastically in order to compete for the highest rankings even when it comes to highly competitive keywords.

Subscribe to our newsletter!

More from our blog

See all posts
No Comments

    Leave a Comment