在wamp上的Laravel 4 htaccess vhost NotFoundHttpException问题

时间:2013-03-29 08:44:22

标签: php apache .htaccess wamp laravel

我在WAMP上安装了Laravel 4的本地副本,Windows 7 64位,运行apache2.4和php5.4。我为这个项目设置了一个虚拟主机,如下所示:

<VirtualHost *:80>
DocumentRoot "c:/Google Drive/project/public"
ServerName project
<directory "c:/Google Drive/project/public">
    Options Indexes FollowSymLinks
    AllowOverride all
    Require all granted
</directory>
</VirtualHost>

当我尝试访问project/时,一切正常。当我尝试从project/index.php?home访问默认的Home控制器时,它也能正常工作。但是,当我尝试从project/home/访问默认的Home控制器时,我得到了Laravel 4引发的NotFoundHttpException

我正在使用Laravel 4提供的默认.htaccess文件:

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

在没有Laravel 4投掷NotFoundHttpException的情况下,从URL中删除index.php的正确方法是什么?

1 个答案:

答案 0 :(得分:0)

您是否尝试过Laravel Docs(请参阅安装 - &gt;漂亮网址)?

“如果Laravel附带的.htaccess文件无法与您的Apache安装一起使用,请尝试以下方法:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

这似乎对我有用。我也在Win7 64位等上使用WAMP(实际上是XAMPP),但我没有使用虚拟主机。

相关问题