How To Enable mod_rewrite in XAMPP, WAMP

Last updated on July 5th, 2024 at 05:56 am

XAMPP and WAMP are popular suites for Windows to run Apache, PHP and MySQL under one roof. They allow you to easily host and manage websites from one place. While running a website, administrators may need to redirect one or more URLs. For this, you need to enable mod_rewrite module in Apache server, which is disabled by default. mod_rewrite is a useful Apache module that allows you to easily redirect and rewrite URLs. If you run Apache web server using XAMPP/WAMP then here are the steps to enable mod_rewrite in XAMPP, WAMP.

What is mod_rewrite

Apache server features tons of modules to do many different kinds of things. Among them, mod_rewrite is a popular one used by web developers and administrators. It allows you to easily rewrite and redirect URLs, folder, domains, virtual hosts and subdomains. They are often used if you are moving web pages or sites from one location to another. By default, they are disabled in Apache server and need to be explicitly enabled.

How To Enable mod_rewrite in XAMPP, WAMP

Here are the steps enable mod_rewrite in XAMPP, WAMP.

1. Backup httpd.conf

We need to make changes to the Apache configuration file. It is better to take its backup so that we can easily recover it in case of issues.

2. Open httpd.conf

Open the Apache configuration file httpd.conf in a text editor. You will find this file in one of the following locations depending on whether you use XAMPP or WAMP.

C:\xampp>\apache\conf

OR 

C:\wamp\bin\apache\Apache2.2.11\conf

3. Enable mod_rewrite

Look for the following line

#LoadModule rewrite_module modules/mod_rewrite.so

Uncomment it by removing # at its beginning.

LoadModule rewrite_module modules/mod_rewrite.so

Find all occurrences of

AllowOverride None

and change them to

AllowOverride All

4. Restart XAMPP,WAMP

Restart XAMPP/WAMP server to apply changes.

That’s it. Now you should be able to use mod_rewrite for URL redirection and URL rewrite.

Conclusion

XAMPP/WAMP applications provide a great GUI-based way to easily manage Apache, PHP and MySQL from one place, and run websites. mod_rewrite is a popular Apache module frequently used to redirect and rewrite URLs. It allows you to easily move website, domains, sub domains, directories and individual URLs without breaking them. We have learnt how to enable mod_rewrite in Apache server. The key is to open Apache configuration file and uncomment the LoadModule statement for mod_rewrite module.

Ubiq makes it easy to visualize data in minutes, and monitor in real-time dashboards. Try it Today!

Also read :
How to Change Default Index Page in Apache
How to Install mod_security in CentOS 7
How to Change Default Timezone in Apache/PHP