Enabling .htaccess on Apache in Windows

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

To enable .htaccess on Apache2 servers such as XAMPP, you need to follow these steps:

  1. Using a text editor, open the httpd.conf file: In XAMPP, this file is located in the apache/conf directory.
  2. Find the following line of code.
    #LoadModule rewrite_module modules/mod_rewrite.so
  3. Remove the # from the line as seen below to enable the mod_rewrite module.
    LoadModule rewrite_module modules/mod_rewrite.so
  4. Save the changes you made to the httpd.conf file and close it.
  5. Restart Apache: Restart the Apache server for the changes to take effect.
    Note: You can do this through the XAMPP control panel.
  6. Create .htaccess file: Create a new file in your website's root directory called .htaccess and 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.