What is .htaccess file

Htaccess file is an Apache web server configuration file that can be used to override some Apache settings for an entire site or a specific folder.

How to create a .htaccess file on Windows ?

If you try to create an .htaccess file in Windows operating systems , the result will be a “File name must be entered” error.

Error creating a .htaccess file on windows.

create a .htaccess file on Windows

To work around this error, you need to create an empty text document and then rename it to .htaccess. (with a dot at the end). After renaming, the extra period will disappear.

If you are using a dedicated text editor, you can most likely create your .htaccess file through it. Instructions for Notepad ++ users:

  • Open Notepad ++
  • Click File -> Save As
  • In the new window, select the file type of all types (Eng. The All types ), enter the .htaccess and save.

Sample .htaccess file

Some of the most popular directives are site encoding and error control settings. Let’s specify them in the .htaccess file:

# Charset
AddDefaultCharset UTF-8

# Errors
php_value error_reporting -1
php_flag display_startup_errors on
php_flag display_errors on

In this example, we have specified the following directives:

  • AddDefaultCharset – indicates the encoding of the site.
  • error_reporting – indicates which level errors to catch (for display on the site and in logs), and which to ignore ( -1 means to catch all errors).
  • display_errors and display_startup_errors – whether to display errors in the browser ( on – display, off – do not display). Usually turned on during development and turned off on a live site.

Now the .htaccess file can be placed in the root folder with the site.

Leave a Reply

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

Leave a Reply

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