How to set the mod_rewrite for Apache in Ubuntu

0
425

Step 1 – Install Apache
This step uses a built-in package installer called apt-get. It greatly simplifies management and makes it easy to install anew.
Update the package index on the computer first. This ensures that older or older packages do not interfere with the installation.

sudo apt-get update

Apache2 is the HTTP server I mentioned earlier and is the world’s most popular server. To install, run the following:

sudo apt-get install apache2

Step 2 — Enabling mod_rewrite
You must now activate mod_rewrite.제 mod_rewrite

sudo a2enmod rewrite

This will indicate that the module has been activated or has already been applied.
Restart Apache for this change to take effect.

sudo service apache2 restart

Step 3 — Setting Up .htaccess

In this section, you set up the .htaccess file for simpler rewrite rule management.

The .htaccess file allows you to modify rewrite rules without accessing server configuration files.
For this reason, .htaccess is important for the security of web applications.
The period that precedes the file name verifies that the file is hidden.

Before you begin, you need to obtain some additional settings.

First, allow changes in the .htaccess file. Use noo or your favorite text editor to open the default Apache configuration file.

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

In this file, there is a block <VirtualHost *: 80> in line 1.
Add the following blocks in the block.

/etc/apache2/sites-available/default
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

The file should now match.
ke sure that all blocks are properly indented.

/etc/apache2/sites-available/default
<VirtualHost *:80>
<Directory /var/www/html>

. . .

</Directory>

. . .
</VirtualHost>

Restart Apache for this change to take effect.

sudo service apache2 restart

LEAVE A REPLY

Please enter your comment!
Please enter your name here