【发布时间】:2021-12-27 03:05:27
【问题描述】:
您好,我正在尝试在 Ubuntu 20.04.3 Apache 2.4.41 PHP 7 服务器上查看 .PHPS 源文件,但是当我在浏览器中查看 .phps 文件时,我收到了这条消息 -
403 Forbidden 您无权访问此资源。
如果我将文件类型重命名为 .txt,我可以在浏览器中正常查看文件。
我已将以下内容添加到 .htaccess -
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
RewriteRule (.*\.php)s$ $1 [H=application/x-httpd-php-source]
我尝试将其添加到 /etc/apache2/sites-enabled/demo.testsite.com-le-ssl.conf,但没有成功。
然后我更新了这个文件 /etc/apache2/mods-available/php7.3.conf 并注释掉了 Require all denied 并且还添加了 Order Deny ,Allow 和 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>
然后我重新启动了 apache sudo service apache2 restart,当查看 PHPS 文件时,我仍然在浏览器中收到此消息 -
403 Forbidden 您无权访问此资源。
有人知道如何解决吗?
【问题讨论】: