Introduction to .htaccess

What is .htaccess?

The Apache Web server utilizes a per-directory access and configuration system under which users can modify and control various aspects of their particular website's operation by creating .htaccess files.

A .htaccess file is simply a text file containing commands referred to as Apache directives. Those directives apply to and effect the files in the directory where the .htaccess file is located as well as to all subdirectories below it.

What can I do using .htaccess files?

.htaccess files can be a very powerful and versatile tool. The list of things one can accomplish using .htaccess includes:

  • password protect specific directories
  • set up custom error pages
  • disable directory listings
  • specify alternate index files
  • ban users by IP address
  • prevent bandwidth theft via 'hotlinking'
  • redirect to specific pages automatically
  • add MIME types
  • parse .html/.htm files for php code

Some of these features (password protection, custom error pages, MIME types) have been automated by controls integrated into cPanel and one can take advantage of these options without manually creating and editing .htaccess files, however the others must be implemented on a DIY basis.

Things To Note

- While HostRocket permits customers to modify and use .htaccess, as a general rule, no technical support is provided for .htaccess customization. While all of the .htaccess information discussed in these FAQs has been tested and verified as working, no guarantees are offered as far as every tip working at all times on every account.

- Users of Microsoft Frontpage who have Frontpage Extensions enabled on their accounts should exercise particular caution if they are considering performing any .htaccess modification as there is a risk of corrupting the Frontpage Extensions.

  • 7 أعضاء وجدوا هذه المقالة مفيدة
هل كانت المقالة مفيدة ؟

مقالات مشابهة

How to redirect a page to another page or website using .htaccess?

If a page on your website no longer exists and you want to redirect it to your new page or...

Blocking users by IP address using .htaccess

Should you find that a few unruly visitors are causing you problems by posting unwanted messages...

Directory protection using .htaccess

One of the more common/popular uses of .htaccess is to password protect specific directories...

Modifying existing .htaccess files

To modify/add directives to the .htaccess file in your public_html directory using "File...

Setting a default index page using .htaccess

By default our servers will look for (in order) a file by the name of index.html, index.cgi,...