Enable the Apache mod_rewrite Module Ubuntu Example

Ubuntu

Nicesnippets

24-06-2022


Enable the Apache mod_rewrite Module Ubuntu Example

Hi Guys,

This tutorial is focused on Ubuntu 22.04 on mod_rewrite Enable. it's simple example of How to mod_rewrite Enable in Apache Ubuntu 22.04?. Here you will learn Steps to mod_rewrite Enable. you'll learn Write Commands mod_rewrite in Apache on Ubuntu 20.04. So, let's follow few step to create example of Steps to Enable mod_rewrite on Ubuntu 22.04.

You can use this post for ubuntu 14.04, ubuntu 16.04, ubuntu 18.4, ubuntu 20.04, ubuntu 21 and ubuntu 22.04 versions.

Use the simple steps below to enable / disable mod_rewrite on an Apache 2 server.

Step 1: Install Apache 2


Use the following command to install the Apache 2 web server

sudo apt-get update

sudo apt-get install apache2

Step 2: Enable mod_rewrite Apache By a2enmod Command

Type the a2enmod command to enable any modules in the Apache 2 web server:

sudo a2enmod rewrite

Step 3: Allow .htaccess File for VirtualHost

open your terminal and type the following command

sudo nano /etc/apache2/sites-available/000-default.conf

You need to add this "AllowOverride All" to your virtualhost configuration file as follows

<VirtualHost *:80>

ServerName www.example.com

DocumentRoot /var/www/html

<Directory /var/www/html>

Options Indexes FollowSymLinks

AllowOverride All

</Directory>

</VirtualHost>

Step 4: Restart Apache 2

Type the following command to restart the Apache 2 server

sudo systemctl restart apache2