Laravel共享主机.htaccess


Laravel Shared Hosting .htaccess

我正在尝试将Laravel项目部署到共享主机上,我已经设法完成了大部分艰苦的工作,但我无法在没有禁止问题的情况下剥离/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>

任何想法?

这是我使用的魔法脚本(添加到public_html中的.htaccess)

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [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>
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^$ public/index.php [L]
    RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
</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>