Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.



Get Started Now!

Apache: The requested URL was not found on this server

Not Found
The requested URL was not found on this server.
Apache/2.4.58 (Win64) OpenSSL/3.1.3 PHP/8.2.12 Server at name Port 443

If you’ve encountered this error while working on your local server setup or even on a production environment, here’s how you can resolve it.

Solution:

This error typically means that Apache couldn’t find the file or directory you’re trying to access. Let’s go through a step-by-step process to troubleshoot and resolve the issue.

1. Check the URL

  • First, make sure that the URL you’re trying to access is correct. Even a small typo in the URL can lead to this error.
  • Ensure that the file or directory exists in the location specified by the URL. For instance, if you’re trying to access http://localhost/example/index.php, make sure the index.php file exists inside the example directory.

2. Directory Indexing Configuration

If you are accessing a directory without specifying a file (like http://localhost/example/), Apache will try to load a default file (like index.php or index.html). If such a file doesn’t exist, you might get the “Not Found” error.

  • Open your Apache configuration file (httpd.conf).
  • Look for the line that defines the DirectoryIndex, which specifies the default files that Apache looks for in a directory. It should look something like this:
DirectoryIndex index.php index.html
  • If this line is missing or doesn’t include the file type you are trying to load, add it and restart Apache.

3. Check File Permissions

Sometimes, the “Not Found” error can be caused by permission issues. Apache needs the appropriate permissions to read the files and directories on your server.

  • Ensure that your files and directories have the correct permissions. On Linux, the chmod command can be used to adjust file permissions:
sudo chmod 755 /path/to/your/directory
sudo chmod 644 /path/to/your/file.php
  • On Windows, make sure that the Apache service has access to the necessary files.

4. Check Apache’s DocumentRoot

Apache serves files from a specific directory, known as the DocumentRoot. If your files are not placed in the correct location or if the DocumentRoot is incorrectly configured, you will get a “Not Found” error.

  • Open your httpd.conf file and look for the DocumentRoot directive. It might look something like this:

DocumentRoot “C:/xampp/htdocs”

  • Ensure that the file you’re trying to access is within the directory specified by DocumentRoot.

5. Check Virtual Hosts Configuration

If you’re using virtual hosts (multiple sites running on the same server), an incorrectly configured virtual host can lead to a “Not Found” error.

  • Open your virtual hosts configuration file (often found in conf/extra/httpd-vhosts.conf or similar).
  • Ensure that the ServerName and DocumentRoot are correctly set for the site you are trying to access. Example:
<VirtualHost *:443>
    ServerName name
    DocumentRoot "C:/path/to/your/site"
    SSLEngine on
    SSLCertificateFile "C:/path/to/ssl/certificate.crt"
    SSLCertificateKeyFile "C:/path/to/ssl/private.key"
</VirtualHost>

Also, verify that the virtual host configuration is included in your main Apache configuration file (httpd.conf), like this:

Include conf/extra/httpd-vhosts.conf

6. Restart Apache

After making any changes to your configuration files, restart the Apache server to apply the changes:

  • On Windows (if using XAMPP or WAMP), you can stop and start the Apache service through the control panel.
sudo systemctl restart apache2

More topics on Bug fixing:

Related Posts

How We Fixed “sonar-scanner: command not found” and Successfully Analyzed Our Project with SonarQube

Running static code analysis with SonarQube is essential for maintaining clean, quality code. Recently, while working on our Laravel microservice project mhn-doctors-ms, we hit a common yet…

Is SonarQube Community free Edition Good for Laravel Projects?

When working on web development projects using Laravel, JavaScript, and jQuery, maintaining code quality becomes just as important as building features. That’s where tools like SonarQube come…

Laravel Throttle Middleware: How to Increase API Rate Limit Safely and for 429 Too Many Requests

If you’re working with Laravel APIs, you might have encountered this default throttle setting: This line lives in your app/Http/Kernel.php file and controls how many requests a…

Fixing MySQL Error: Incorrect Definition of mysql.column_stats Table

The Problem While working on your MySQL server, you might come across this error in your error log: This error usually shows up after an upgrade or…

Fixing Laravel Migration Error: “Unknown Collation: utf8mb4_0900_ai_ci”

While working with Laravel and MySQL, you might run into an error during migrations like this one: Why This Happens The collation utf8mb4_0900_ai_ci is introduced in MySQL…

Why Dental Surgery Is Good and Important

Dental health plays a vital role in our overall well-being, yet it’s often overlooked until problems become serious. Dental surgery is a powerful solution that not only…

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x