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)