How to Activate mod_rewrite and Enable .htaccess files on Apache2 Web Server

Zaid Jaber by Zaid Jaber
How to Activate mod_rewrite and Enable .htaccess files on Apache2 Web Server

In this tutorial, we will activate Apache 2s mod_rewrite module. This module allows us to rewrite URLs in a cleaner way, translating human-readable paths into code-friendly query strings or redirecting URLs based on additional conditions.

Step 1: Activate mod_rewrite

Open your terminal and write the following command

~$ sudo a2enmod rewrite

In order to make this change take place you need to restart apache2.service by typing the following command:

~$ sudo systemctl restart apache2.service

Now mod_rewrite is activated.

Step 2: Enable .htaccess files

You need to make some changes to the Apache2 config file
write the following command in your terminal

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

Inside the find and Copy & Paste the as shown below:



Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all



Now restart Apache2.service

~$ sudo systemctl restart apache2.service

Now .htaccess is ready to be used.

Step 3: Testing .htaccess file

Create .htaccess file inside your /var/www/html/

Write the following

RewriteBase /
RewriteEngine On

If you did not get Internal Server Error, then you are good to go.

Thats all. Thanks

Follow Me
https://www.keefto.com/accounts/zaidjaber

Category: How To

Comments (0)

Read More

How to enable Dark Mode... omg In this article we will be taking a look on how to enable dar...
How to enable Audio des... omg In this article we will take alook on how to eale audio descri...
How to disable GPS loca... omg In this article we will take alook on how to disable the GPS lo...
How to install Signal P... omg In this article we will take alook on how to install signal pri...
How to delete Imo Accou... omg In this article we will take alook on how to delete yout Imo Ac...
How to share your locat... omg In this tutorial we will take a look on how to share your locat...