Start a conversation

Other basic .htaccess features

In this article, we'll look at a few more directives that will be useful when developing and customizing your own website.

The .htaccess file can be used to determine the encoding of the website. The default encoding is set using the following directive:

AddDefaultCharset UTF-8

It is also possible to define the encoding only for a certain type of files. Example of defining encoding for HTML files:

AddType "application/x-httpd-php3; charset=windows-1251" .html

Using the .htaccess file, you can define the index file (the file that will be loaded when you enter the site):

DirectoryIndex index.php

You can also define the scope of directives using FilesMatch using regular expressions. For example, you can block access to files of a certain type:

<FilesMatch
"\.(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$">
Order Allow,Deny
Deny from all
</FilesMatch>

Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Alexey Momot

  2. Posted
  3. Updated

Comments