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 For while now most of companies are going forward with enabling...
How to create a bootabl... omg In this article we will take a look on how to create a bootable...
lHow to install TablePl... omg In this article we will take alook on new Database IDE called T...
How to enable dark mode... omg In this article we will take a look on how to enable dark mode ...
How to Clear Viewing Ac... omg In this article we will take a look on how to clear your viewin...
Now to install Atom tex... omg In this tutorial we will take alook on how to install Atom Text...