Laravel 4 .htaccess 不重写 URL [英] Laravel 4 .htaccess Not Rewriting URLs

查看:24
本文介绍了Laravel 4 .htaccess 不重写 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我刚刚升级到 Laravel 4,我正在新服务器上进行设置.默认的 / 路由可以正常工作,但其他所有路由都会返回 404 错误.尝试 index.php/route 时,我得到了请求的数据,这意味着 .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 模块.

我尝试了以下 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,所以我的公共文件夹是 public/site1public/site2public/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 中编辑虚拟主机了.呸呸呸.补充:

I forgot to edit the vhosts in httpd.conf. Derp, derp. Added:

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

到每个站点的虚拟主机文件,它工作得很好.嘭嘭嘭.

to each of the site's vhost files, and it worked beautifully. Derp derp.

这篇关于Laravel 4 .htaccess 不重写 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆