簡體   English   中英

PHPS 源文件 - 403 Forbidden 您無權訪問此資源

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

嗨,我正在嘗試在 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、AllowDeny 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 您無權訪問該資源。

有沒有人知道如何解決?

Apache 2.4 已棄用Allow,Deny語法。 代替

Order Deny,Allow
Deny from all

Require all granted

然后重新啟動Apache。

參考

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM