phpapacheserverlampubuntu-22.04

Receiving 403 Forbidden Error in PHP on Ubuntu 22.04


I am encountering a persistent issue where I receive a 403 Forbidden error whenever I attempt to access any PHP file within directories on my Apache web server, except for index.php. This problem appeared suddenly without any recent major changes to the configuration.

Here are the details of the problem:

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

I have tried various troubleshooting steps, including checking Apache configurations, file permissions, and .htaccess files, but I have not been able to resolve this issue.

Can anyone provide insights or suggestions on how to debug and fix this 403 Forbidden error for PHP files within directories on my Apache web server?

Update: By setting AllowOverride None in apache2.conf solved my problem. But I wanted the custom .htaccess rules also in the directory to apply.

Thank you in advance for your assistance!


Solution

  • This error was raised by mine earlier time fault only. In the web root of our domain. This .htaccess code is there:

    <Files *.php>
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1
    </Files>
    
    <Files index.php>
        Order Allow,Deny
        Allow from all
    </Files>
    

    So, after fixing the code, my project works properly. Thanks all of you for my help in my own fault by giving your precious time.