簡體   English   中英

Laravel 共享主機 .htaccess

[英]Laravel Shared Hosting .htaccess

我正在嘗試將 Laravel 項目部署到共享主機上,我已經設法完成了大部分艱苦的工作,但是如果沒有 Forbidden 問題,我無法剝離 /public 目錄。

該網站工作並顯示這些鏈接的相同頁面

  • www.mywebsite.com/test/index.php
  • www.mywebsite.com/test/public/

但是沒有 /index.php 它返回 ->

Forbidden

You don't have permission to access /test/ on this server. 

目前我的 .htaccess 如下所示。

<IfModule mod_rewrite.c>

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ public/index.php [L]

</IfModule>

有任何想法嗎?

test/.htaccess試試這個規則:

DirectoryIndex index.php
<IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteBase /test/

    RewriteRule ^$ public/index.php [L]

    RewriteRule ^((?!public/).*)$ public/$1 [L,NC]

</IfModule>

這是我使用的魔法腳本(添加到public_html.htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

這個腳本對我有用。

<IfModule mod_rewrite.c>
   RewriteEngine On
   # Force SSL
   RewriteCond %{HTTPS} !=on
   RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
   # Remove public folder form URL
   RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
RewriteEngine On RewriteRule ^$ public/index.php [L] RewriteRule ^((?!public/).*)$ public/$1 [L,NC]

對我來說,問題是我的存儲文件夾(和子文件夾)沒有正確的權限。

如果您使用 FileZilla 上傳,您可以簡單地:

  • 右鍵單擊您的資源
  • 轉到權限
  • 選中所有框並將輸入更改為 777

同樣在我的主機上,我需要將 public 更改為 httpdocs。 但這在您的主機上可能有所不同。

暫無
暫無

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

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