[英]Routing in Laravel and httpd.conf
I've set my document root as follows: 我将文档根目录设置如下:
c:/wamp/www/laravel/public
When I test localhost on the browser I get the "You have arrived" page. 当我在浏览器上测试localhost时,出现“您已经到达”页面。
However when I try localhost/page0, I get a 404. 但是,当我尝试localhost / page0时,我得到了404。
In my routes.php file I have this: 在我的routes.php文件中,我有这个:
Route::get('/', function()
{
return View::make('hello');
});
Route::get('page0', function() {
return 'Test Helloworld! 0';
});
My .htaccess file looks like this: 我的.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>
It looks like everything should work. 看起来一切正常。 Why doesn't this work?
为什么不起作用?
You might want to check if mod_rewrite is enabled by doing: 您可能想通过以下操作检查是否启用了mod_rewrite:
phpinfo();
You can issue this in your routes.php
. 您可以在
routes.php
发布它。
It is also possible to start a webserver in php like so from the terminal or command prompt depending on your OS: 也可以像这样从终端或命令提示符启动php中的网络服务器,具体取决于您的操作系统:
php -S localhost:8080 -t public/
Do this from your project root. 从项目根目录执行此操作。 Then you can go to:
然后,您可以转到:
localhost:8080
And your site should be up and running. 并且您的站点应该已启动并正在运行。 You can still use the MySQL server that is running from XAMPP or WAMPP.
您仍然可以使用从XAMPP或WAMPP运行的MySQL服务器。
Use 采用
c:/wamp/www/laravel/public/page0
This should work. 这应该工作。
For production and/or development you can set the document root to the "public" folder, to get rid of the "/public/" in your url: 对于生产和/或开发,您可以将文档根目录设置为“ public”文件夹,以摆脱URL中的“ / public /”:
@see https://stackoverflow.com/a/15469480/1854296 (for example) @请参阅https://stackoverflow.com/a/15469480/1854296 (例如)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.