Question

PHPS source file - 403 Forbidden You don't have permission to access this resource.

Hi I am trying to view a .PHPS source file on Ubuntu 20.04.3 Apache 2.4.41 PHP 7 server but when I view the .phps file in the browser I get this message -

403 Forbidden
You don't have permission to access this resource.

If I rename the file type to .txt I can view the file fine in the browser.

I’ve added the following to .htaccess -

<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
</FilesMatch>

RewriteRule (.*\.php)s$ $1 [H=application/x-httpd-php-source]

And I tried adding that to /etc/apache2/sites-enabled/demo.testsite.com-le-ssl.conf but it didn’t work.

I then updated this file /etc/apache2/mods-available/php7.3.conf and commented out Require all denied and also added Order Deny,Allow and Deny from all -

<FilesMatch ".+\.phps$">
    SetHandler application/x-httpd-php-source
    # Deny access to raw php sources by default
    # To re-enable it's recommended to enable access to the files
    # only in specific virtual host or directory
    #Require all denied
    Order Deny,Allow
    Deny from all
</FilesMatch>

I then restarted apache sudo service apache2 restart and I still get this message in the browser when viewing the PHPS file -

403 Forbidden
You don't have permission to access this resource.

Has anyone got any idea how to fix?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
November 16, 2021
Accepted Answer

Hello,

I could suggest checking your Apache error log for some more information, you could use the following command to do so:

tail -100 /var/log/apache2/error.log

Also, can you confirm which tutorial did you follow to set up your Apache and PHP installations?

Best, Bobby

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.