What is. Htaccess?

The .htaccess file is configuration file is used on web servers running apache web server software. It is able to override server configuration settings. .htaccess is used for authorization, website optimization, cache control and URL rewriting. CMS (content management system) like WordPress, htaccess file is mostly used for rewriting URLs. This makes them cleaner, more readable by humans and search engines. In settings, permalinks section of WordPress administration, you have option to select your URL structure. WordPress will automatically rewrite .htaccess file to handle the URL. If WordPress is unable to write file. It will ask you to do this manually. Manually editing .htaccess file is risky. It can cause major server errors. Plugins like W3 total cache will modify your .htaccess file in order to configure the caching and optimization tools. .htaccess file in usually found in root directory. FTP client is unable to show it, by default all directories and files names starting with period are considered hidden. For viewing hidden files you have to enable show hidden files.

Creating an Htaccess file: –

Htaccess files uses by default filename – “.htaccess” is specified from main server config using AccessFileName directive.

Unlike main server configuration files like httpd.conf. Htaccess files are read on every request. Because of continuous access changes in these files take immediate effect. Apache searches subdirectories and all directories that are htaccess enabled. Htaccess files follows same syntax as main apache configuration files.

One of the major difference is context of directive. This means whether or not directive is ALLOWED to use inside .htaccess file. Htaccess files are incredibly powerful and can be very dangerous as some directives allowed main configuration files.

Uses of .htaccess file: –

Typical usage of .htaccess file are rewriting and redirecting URLs. Administration of error documents and access protection for files and entire directories.

  • Rewriting Dynamic to Static URL – Using Apache module mod-rewrite that is installed and activated. Dynamic URL can be rewritten in such a way that it looks like static URL for search engines and humans.

  • Redirection from old to new URL – Redirecting from old URL is a good option when you require to do domain transfer such as – relaunch, restructuring and other reasons.

  • Redirecting with www and without www – Many domains are retrieved with www and without www. Redirection without www to with www is very important to avoid duplicate content.

  • Protecting image theft – htaccess file is a way to prevent user from downloading image from website or inserting. This not only safeguards your images from theft. It also prevents traffic being stolen.

  • Importance of SEO – Rewriting and redirecting URLs in particular are importance for search engine optimization. Redirecting status is significant from SEL perspective. If nothing is specified, servers will interpret this as temporary redirect.

Conclusion: –

Thus, htaccess is very important file used for various purposes. From creating htaccess file to the usage of htaccess file. Htaccess file is used in rewriting URLs used in authorization, optimization. For better migration and hosting connect with HTS Hosting, best cloud hosting company providing cPanel hosting, Windows shared web hosting and other hosting plans.

Leave a Reply

Your email address will not be published. Required fields are marked *