Skip to main content

Knowledge base

Configuring the mod_rewrite on Apache Web Server

A redirect on your Web server is a change of end destination for the client request.

For example, the website has moved to a new domain and a redirect is set from its old URL, so that visitors will automatically go to to the new address using the old URL in their browsers, and the website will successfully load. If you installed an SSL certificate, your website should operate on the https protocol instead of the http protocol, which also requires a redirect set up.

Any Apache Web server redirect rules will work only if the module is enabled. On CentOS OS the module is enabled by default, on Debian and Ubuntu it may need to be added. To do this, run the command:

sudo a2enmod rewrite

If the module is already installed, a message will appear:

In the Apache configuration file /etc/apache2/apache2.conf add the line:

AllowOverride all

This will further enable the use of mod_rewrite module commands in the .htaccess file. Restart the Web server using the command:

apachectl restart или apache2ctl restart

Return to category