How to enable mod_rewrite for Apache?

For enable mod_rewrite for Apache.

If you are using Ubantu OS and you have apache web server

Step 1 : open your terminal using ctrl + alt +t.

Step 2 : Then wirte

sudo a2enmod rewrite

Step 3 :

sudo service apache2 restart

Step 4: Then, if you’d like, you can use the following .htaccess file.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

If you are using Windows os and you have WAMP or XAMPP

Wamp and XAMPP doesn’t come with default rewrite rule enabled, For enabling the rewrite rules in both of them you need to make changes in httpd.conf so that apache can work with rewrite rules.

For enabling the rewrite rules follow these rules:-

Step 1 : find httpd.conf (usually this file can be found in folder callled conf , config or something along those lines)

Step 2: Find and uncomment the line LoadModule rewrite_module .

Step 3:Find the line with DocumentRoot “C:/path/to/my/root”, There you will find contents like

Options All
AllowOverride All

Step 4: All done now restart the Apache server and you will be all good to go.

1 thought on “How to enable mod_rewrite for Apache?

Leave your comments

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s