.htaccess Laravel和httpd.conf中的路由

.htaccess Laravel和httpd.conf中的路由,.htaccess,laravel,routing,httpd.conf,.htaccess,Laravel,Routing,Httpd.conf,我已按如下方式设置了文档根目录: c:/wamp/www/laravel/public 当我在浏览器上测试localhost时,我会看到“youhavearright”页面 然而,当我尝试localhost/page0时,我得到了404 在我的routes.php文件中,我有以下内容: Route::get('/', function() { return View::make('hello'); }); Route::get('page0', function() { re

我已按如下方式设置了文档根目录:

c:/wamp/www/laravel/public
当我在浏览器上测试localhost时,我会看到“youhavearright”页面

然而,当我尝试localhost/page0时,我得到了404

在我的routes.php文件中,我有以下内容:

Route::get('/', function()
{
    return View::make('hello');
});

Route::get('page0', function() {
    return 'Test Helloworld! 0';
});
我的.htaccess文件如下所示:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

选项-多视图
重新启动发动机
#重定向尾部斜杠。。。
重写规则^(.*)/$/$1[L,R=301]
#处理前控制器。。。
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]
看来一切都会好起来的。为什么这不起作用?

使用

c:/wamp/www/laravel/public/page0 
这应该行得通

对于生产和/或开发,您可以将文档根目录设置为“public”文件夹,以删除url中的“/public/”:


@请参阅(例如)

您可能希望通过执行以下操作来检查是否启用了mod_rewrite:

phpinfo();
您可以在
routes.php
中发布此消息

根据您的操作系统,也可以从终端或命令提示符启动php中的Web服务器,如下所示:

php -S localhost:8080 -t public/
从项目根目录执行此操作。然后您可以转到:

localhost:8080

您的站点应该已经启动并运行。您仍然可以使用从XAMPP或WAMPP运行的MySQL服务器。

一切正常。您是否还可以执行以下测试:
returnview::make('hello')从您的
page0
路径?我尝试了:localhost/index.php/page0,这很有效。我怎样才能让它工作呢?只需执行:localhost/page0?听起来好像您的apache重写模块没有启用。这就解决了问题。谢谢