How to install Apache "mod_rewrite" on your Web server

Once you have successfully installed the Apache server and the "mod_rewrite" module, you have to enable it with the following command in your terminal:

sudo a2enmod rewrite

Then you have to edit the Apache configuration file.

The Apache configuration file depends on your operating system.
For CentOS, Fedora and other OS based on Red Hat, the Web server configuration file will normally be "/etc/httpd/conf/httpd.conf".
For Ubuntu and other OS based on Debian, the Web server configuration file will normally be "/etc/apache2/sites-enabled/000-default.conf".

Now, change "AllowOverride None" to "AllowOverride All" inside the DocumentRoot Directory Directive, normally "<Directory "/var/www">".
If "<Directory "/var/www">" isn't present, add <Directory "/var/www">AllowOverride All</Directory> inside of "<VirtualHost></VirtualHost>" tags.

Now, save the file (you need to have the administrative privileges), and restart your Apache server.


I hope this help will be useful and will save you much time.

P.S., Normally, all shared hosts are already configured to work with Apache mod_rewrite and allow configuration via .htaccess


For checking if everything is OK and pH7Builder will be able to work, you can use this test rewriting script.


📝 Found a typo/something to add? Edit this Page ✍️