Enable htaccess on Apache2. By default XAMPP and similar Apache Web Servers that can be run from Windows do not have mod_rewrite enabled. This causes Apache to ignore an .htaccess file. In the following simple solution, I show you how to enable mod_rewrite to enable the use of .htaccess on Apache servers in Windows like XAMPP. Moreover, this allows you to create nice permalinks for software like WordPress.
How to enable .htaccess on Apache2 in Windows
.htaccess on Apache2 servers such as XAMPP, you need to follow these steps:
- Using a text editor, open the
httpd.conffile: In XAMPP, this file is located in the
- Find the following line of code.
#LoadModule rewrite_module modules/mod_rewrite.so
- Remove the # from the line as seen below to enable the
LoadModule rewrite_module modules/mod_rewrite.so
- Save the changes you made to the
httpd.conffile and close it.
- Restart Apache: Restart the Apache server for the changes to take effect.
Note: You can do this through the XAMPP control panel.
.htaccessfile: Create a new file in your website's root directory called
.htaccessand add your rewrite rules to this file.
Now you have successfully enabled
.htaccess on Apache2. You can use this file to control access to directories, redirect URLs, and more. If all went well, you should be able to use htaccess files on your server and create nice permalinks within WordPress.