Laravel htaccess 问题 [英] Laravel htaccess issue
问题描述
我正在尝试将网站设为直播.该站点在我们一直用来向客户端显示站点的实时开发服务器上运行得非常好.这是来自实时开发人员的 htaccess(工作正常):
I'm trying to set a site live. The site works perfectly fine on a live dev server which we've been using to show the site to the client. Here is the htaccess from the live dev (works fine):
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
#RewriteCond %{HTTPS} !=on
#RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
#RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Rewrite to 'public' folder
RewriteCond %{HTTP_HOST} ^livedev.domain.com$
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) public/$1 [L]
</IfModule>
AuthType Basic
AuthName "dev16"
AuthUserFile "/home/site/.htpasswds/public_html/passwd"
require valid-user
这是来自实时站点的 .htaccess:
And here's the .htaccess from the live site:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
#RewriteCond %{HTTPS} !=on
#RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
#RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Rewrite to 'public' folder
RewriteCond %{HTTP_HOST} ^livesite.co.uk$
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) public/$1 [L]
</IfModule>
除了 HTTP_HOST 和取消身份验证之外,这两个是相同的.
The 2 are identical except for the HTTP_HOST and the removal of the authentication.
它给了我一个通用的内部服务器错误".
It gives me a generic "Internal Server Error".
我尝试删除 .htaccess 的内容,这只是给我找不到页面,所以问题肯定出在 .htaccess 上.
I have tried deleting the contents of .htaccess which just gives me page not found so the issue definitely lies in .htaccess.
完全 .htaccess 处女,我可以采取哪些步骤来找到问题的原因?
A total .htaccess virgin, what steps can I take to find the cause of the issue?
谢谢
(这是 Laravel 3.2.13)
(It's Laravel 3.2.13)
推荐答案
与/public同级使用
这种方式先重定向到public
This way first redirect to public
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]
在/public 里面
然后,你处理 index.php
then, you handle index.php
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
</IfModule>
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
这篇关于Laravel htaccess 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!