![](/img/trans.png)
[英]Wordpress 403 Forbidden Access to this resource on the server is denied
[英]403 Forbidden Access to this resource is denied on server- Laravel 5.7
我正在Laravel 5.7
處理一個項目。 一切都在本地主機上工作。 但是,在服務器中上傳后, Backend Part
所有路由都在工作。 但是Frontend Part
發布路由不起作用。 它顯示錯誤 -
403 Forbidden 對服務器上此資源的訪問被拒絕
根文件夾中的.htaccess
是 -
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
以前有人遇到過這個問題嗎? 我錯過了什么。 在 localhost 中一切正常,但在 Server 中卻沒有。
我認為您沒有生成工匠密鑰。 請在服務器上運行這些命令。
composer update
php artisan key:generate
你的 htaccess 應該是這樣的
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$public /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
要處理/public
前端內容,請將其添加到您的.htaccess
:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
.htaccess 對我來說看起來不錯 確保你的 post 路由是用表單調用的。
如果您的后端沒有問題,那么
您需要向這些目錄的服務器授予權限
授予 bootstrap/ 和 storage/ 目錄的權限,如下所示
sudo chmod -R 777 storage/ bootstrap/
那么它應該工作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.