.htaccess file is a configuration file used on web servers that run the Apache software. It is a hidden file that is usually located in the root directory of a website.
The purpose of an
.htaccess file is to allow the server administrator to configure the behavior of the server and control access to certain directories or files. This can include setting up redirects, enabling password protection, blocking IP addresses, enabling compression, and much more.
The file is written in plain text and contains directives or rules that tell Apache how to handle requests for files and directories. The directives can apply to the whole website or to specific directories or files within the website.
To use a different
.htaccess file in your MAMP environment compared to your production server, you can create another .htaccess file with a unique name.
Change the .htaccess filename for a specific Virtual Host:
1. Open up your MAMP vhost conf file:
2. Use the AccessFileName directive with your desired new filename for .htaccess in each Virtual Host:
<VirtualHost *:80> DocumentRoot /Applications/MAMP/htdocs ServerName localhost AccessFileName _.htaccess.testing </VirtualHost>
The above virtual host would now use _.htaccess.testing as its .htaccess file, if it exists.
Globally change the .htaccess filename in MAMP:
1. Open the Apache config file in MAMP:
2. Scroll down to the AccessFileName derective and enter your new
All you need to do now is to restart Apache in MAMP and the new setting will take effect.