Laravel htaccess 问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15946186/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel htaccess issue
提问by Fraser
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):
我正在尝试设置一个网站。该站点在我们一直用来向客户端显示站点的实时开发服务器上运行良好。这是来自实时开发人员的 htaccess(工作正常):
<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/ [L]
</IfModule>
AuthType Basic
AuthName "dev16"
AuthUserFile "/home/site/.htpasswds/public_html/passwd"
require valid-user
And here's the .htaccess from the live site:
这是来自实时站点的 .htaccess:
<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/ [L]
</IfModule>
The 2 are identical except for the HTTP_HOST and the removal of the authentication.
除了 HTTP_HOST 和身份验证的删除之外,这 2 个是相同的。
It gives me a generic "Internal Server Error".
它给了我一个通用的“内部服务器错误”。
I have tried deleting the contents of .htaccess which just gives me page not found so the issue definitely lies in .htaccess.
我已经尝试删除 .htaccess 的内容,这只是给我找不到页面,所以问题肯定出在 .htaccess 上。
A total .htaccess virgin, what steps can I take to find the cause of the issue?
一个完整的 .htaccess 处女,我可以采取什么步骤来找到问题的原因?
Thanks
谢谢
(It's Laravel 3.2.13)
(这是 Laravel 3.2.13)
采纳答案by RamiroRS
Use at same level of /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/ [L]
And inside /public
在 /public 里面
then, you handle index.php
然后,您处理 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/ [L]
</IfModule>
回答by ruuter
I had exactly same setup as RamiroRS answer, but still got Internal Server Error. My problem was in file permissions. Folders should be 0755 and files 0644.
我的设置与RamiroRS answer完全相同,但仍然出现内部服务器错误。我的问题是文件权限。文件夹应该是 0755,文件应该是 0644。