Apache’s mod_rewrite module lets you rewrite URLs more cleanly, translating human-readable paths into code-friendly query strings. It also enables you to rewrite URLs based on conditions. An .htaccess file lets you create and apply rewrite rules without accessing server configuration files. By placing the .htaccess file in the root of your web site, you can manage rewrites on a per-site or per-directory basis.
Apache’s mod_rewrite
module lets you rewrite URLs more cleanly, translating human-readable paths into code-friendly query strings. It also enables you to rewrite URLs based on conditions.
An .htaccess
file lets you create and apply rewrite rules without accessing server configuration files. By placing the .htaccess
file in the root of your web site, you can manage rewrites on a per-site or per-directory basis.
In this tutorial, you’ll enable mod_rewrite
and use .htaccess
files to create a basic URL redirection, and then explore a couple of advanced use cases.
To follow this tutorial, you will need:
In order for Apache to understand rewrite rules, we first need to activate mod_rewrite
. It’s already installed, but it’s disabled on a default Apache installation. Use the a2enmod
command to enable the module:
sudo a2enmod rewrite
This will activate the module or alert you that the module is already enabled. To put these changes into effect, restart Apache.
sudo systemctl restart apache2
mod_rewrite
is now fully enabled. In the next step, we will set up an .htaccess
file that we’ll use to define rewrite rules for redirects.
.htaccess
An .htaccess
file allows us to modify our rewrite rules without accessing server configuration files. For this reason, .htaccess
is critical to your web application’s security. The period that precedes the filename ensures that the file is hidden.
This brief tutorial shows students and new users how to quickly and easily install Apache Maven on Ubuntu 20.04 | 18.04. Apache Maven comes with the default Ubuntu repositories… so all it takes is…
This brief tutorial shows students and new users how to install Apache Ant on Ubuntu 20.04 | 18.04. Apache Ant is a Java library and tool that has number of built-in tasks allowing to compile, assemble, test and run Java applications. Apache Ant is a Java library and tool that has number of built-in tasks allowing to compile, assemble, test and run Java applications. If you’re...
This brief tutorial shows students and new users how to install Apache ActiveMQ on Ubuntu 20.04 | 18.04 server. For those who don’t know, Apache ActiveMQ is a free, multi-protocol, Java-based message…
Jenkins is an open-source automation server that helps to automate the repetitive tasks involved in the software development process, which includes building, testing, and deployments. Jenkins was forked from the Oracle Hudson project and written in Java. Here, we will see how to install Jenkins on Ubuntu 20.04 / Ubuntu 18.04.
Install phpMyAdmin on Ubuntu 20.04 | 18.04 with Apache - PhpMyAdmin is an open source web-based tool that allows users to easily manage MySQL or MariaDB…