Enable rewrite module in Xampp, Wamp, Lamp and apache

Enable rewrite module in Xampp, Wamp, Lamp and apache

There might be a number of situations where we need to enable rewrite module in apache for Xampp, Wamp, Lamp . Let support we have installed laravel application or any other framework and it is working fine but only homapage. Other url of frameworks are not working. It means url rewriting is not working.

If you get a problem like only homepage is working and other urls are not working then there may be two problems. First one may be that rewrite module is not enabled for url rewriting and second one is if your applicaiton has missing .htaccess file.

For enabling url rewrite module you will have to locate apache configuration file and enable it from there. Here are the steps to enable rewrite module.

  1. Open your apache’s configuration file that is generally located in {path of apache directory}/conf/httpd.conf

     2. Now for Xampp and Wamp, find the string “#LoadModule rewrite_module modules/mod_rewrite” in httpd.conf file and remove hash symbol(#) from this string like below. It means you are uncommenting this commented string.

From
#LoadModule rewrite_module modules/mod_rewrite.so 

To
LoadModule rewrite_module modules/mod_rewrite.so 

For Lamp or Mamp, you will need to run the following command to enable rewrite module (mod_rewrite ) for apache in your terminal.

sudo a2enmod rewrite

3. After enabling you will need to allow override all from your virtual host file or .htaccess file which is set by default None.

From 
 AllowOverride None

To
 AllowOverride All

4. After doing all the changes mentioned above, you will need to restart your apache service by directly from wamp and xampp control panel or using the command below in lamp or mamp.

sudo service httpd restart
or
sudo service apache2 restart

You can also read the article to send asynchronous request from php by clicking o the link below.

How to make asynchronous requests in php with example