Laravel 4的.htaccess不重写URL [英] Laravel 4 .htaccess Not Rewriting URLs
问题描述
所以,我刚刚升级到Laravel 4,和我设置的事情了一个新的服务器上。默认 /
路由工作正常,但所有其他路径返回404错误。当试图的index.php /路由
,我得到的请求的数据,这样就意味着的.htaccess不工作。
So I've just upgraded to Laravel 4, and I'm setting things up on a new server. The default /
route works fine, but every other route returns a 404 error. When trying index.php/route
, I get the requested data, so that means that .htaccess isn't working.
是的AllowOverride设置为ALL
。
是的,我启用mod_rewrite的模块
。
Yes, AllowOverride is set to ALL
.
Yes, I enabled the mod_rewrite module
.
我曾尝试以下3的.htaccess组合:
I have tried the following 3 .htaccess combinations:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
和
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
和
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
和,重新启动服务器,等等之后,他们没有工作,我还在返回404错误。
And, after a server restart, and so on, none of them are working, and I'm still returning a 404 error.
注:我使用的几个域具有相同laravel安装,所以我的公共文件夹公共/ site1的
,公共/站点2
,公共/ site3
。不过,我的路由公众路径这些文件夹,所以我不知道这将是一个问题。
Note: I am using several domains with the same laravel install, so my public folders are public/site1
, public/site2
, public/site3
. However, I am routing the public paths to these folders, so I'm not sure that would be the problem.
有什么想法?
推荐答案
我忘了在httpd.conf编辑的虚拟主机。 DERP,DERP。 补充:
I forgot to edit the vhosts in httpd.conf. Derp, derp. Added:
<Directory "/var/www/public/site1">
AllowOverride All
</Directory>
到每个站点的虚拟主机文件,和它的工作精美。 DERP DERP。
to each of the site's vhost files, and it worked beautifully. Derp derp.
这篇关于Laravel 4的.htaccess不重写URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!