2013-06-04 31 views
13

所以我刚刚升级到Laravel 4,我正在设置一台新的服务器。默认/路由工作正常,但其他路由返回404错误。尝试index.php/route时,我收到了所需的数据,因此这意味着.htaccess不起作用。Laravel 4 .htaccess不重写网址

是的,AllowOverride is set to ALL
是的,我enabled the mod_rewrite module

我曾尝试以下3个的.htaccess组合:

<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错误。

注:我使用几个域相同的laravel安装,所以我的公共文件夹是public/site1,public/site2,public/site3。但是,我将公共路径路由到这些文件夹,所以我不确定这会是什么问题。

有什么想法?

+0

你的服务器是什么? xAMP,Apache?你有加载重写模块吗?检查你的httpd.conf中的这一行:'LoadModule rewrite_module modules/mod_rewrite.so' –

+0

@AlexandreButynski Apache。是的,我加载了重写模块。我在上面说过。并且AllowOverride是All。我不知道是什么原因造成的。 –

回答

20

我忘了编辑httpd.conf中的虚拟主机。 Derp,derp。 补充:

<Directory "/var/www/public/site1"> 
    AllowOverride All 
</Directory> 

到每个站点的虚拟主机的文件,而且它漂亮的工作。 Derp derp。