How to use .htaccess file on an Apache Localhost Server
.htaccess is a configuration file that should be stored where your page is.
In short, it should be in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\ (or) custom folder --> D:\dev\www\.
Don't forget to turn on mod_rewrite by deleting a hash from the line where it resides LoadModule rewrite_module modules/mod_rewrite.so and enable .htaccess by changing AllowOverride None to AllowOverride All
This was clearly explained as follows:
- Find your apache directly which uses the php installation
- Open your httpd.conf with notepad, Which is located in the path \apache\conf directory
- Find the code like below
#LoadModule rewrite_module modules/mod_rewrite.so
#from above code
- Make sure the line is
AllowOverride Noneas shown below.
# AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride All <--- change this line to AllowOverride None
- Save httpd.conf file
- Restart your apache server