When you install Apache2 on a Linux server. At that time mod_Rewrite module is not enabled by default on apache 2. And of which website or app you run on the server, and you open any url of this, then you see the message “the requested url was not found on this server apache2 ubuntu”.
So in the tutorial “the requested url was not found on this server apache2 ubuntu” you will learn how to enable rewrite_module and solve this error.
The apache Mod_rewrite is very popular for rewriting human-readable URLs in dynamic websites. This makes the URL’s look cleaner and SEO-friendly on websites. In this tutorial, we will show you how to enable the apache/2.4.5 ubuntu mod_rewrite module and configure it for use .htaccess files available with apache 2 ubuntu web server at port 443, 80.
How to enable rewrite module in apache ubuntu 16.04/18.04/20.04/22.04
Steps to fix the requested url was not found on this server apache/2.4.29 (ubuntu) server at port 443, 80:
Step 1 – Update dependencies
If you are not installed apache 2 in ubuntu. So, you can use the following command to install apache 2 web server:
sudo apt-get update
Step 2 – Enable mod_rewrite Apache By a2enmod Command
To enable/activate rewrite_module in apache server, simply type sudo a2enmod rewrite
on command line or terminal to resolve requested url was not found on this server apache/2.4.5 ubuntu server at port 443, 80 error:
sudo a2enmod rewrite
Step 3 – Allow .htaccess File for VirtualHost
To add “AllowOverride All” in default.conf VirtualHost configuration file to allow .htaccess file, Use sudo nano /etc/apache2/sites-available/000-default.conf
command on command line to open 000-default.conf
file:
sudo nano /etc/apache2/sites-available/000-default.conf
Then you need to add this “AllowOverride All” in your VirtualHost configuration file like below
<VirtualHost *:80> ServerName www.example.com DocumentRoot /var/www/html <Directory /var/www/html> Options Indexes FollowSymLinks AllowOverride All </Directory> </VirtualHost
Note that – The main reason is to enable or allow .htaccess file in the Apache server. Because it does not allow by default. So, you can not use of ‘.htaccess’ file.
Step 4 – Restart Apache 2
If you have follow above 3 steps successfully. Now, You need to restart Apache 2 server to restart all configuration to the running environment.
sudo systemctl restart apache2
Congratulation!! you have successfully enabled/allowdc mod_rewrite in apache 2 web server.
Your Post help me a lot i was looking for the solution. Thanks Devendra Dode
Thanks mate!
Worked in Ubuntu 22.04.