[英]Laravel 5 - Home Page Route
I have a route issue, I can't point localhost/test/
into my index page of my site. 我遇到了路由问题,无法将
localhost/test/
指向站点的索引页面。
When I define a route like: 当我定义一条路线时:
`Route::get("/",IndexController@index);`
localhost/test/
would work fine , but also localhost/test/admin
, localhost/test/en
localhost/test/foo
localhost/test/undefined-route
and will load my index page of the site. localhost/test/
可以正常工作,但localhost/test/admin
, localhost/test/en
localhost/test/foo
localhost/test/undefined-route
也可以,并会加载我的站点索引页。
and beside when I have namespace Route like: 还有当我有命名空间Route时:
Route::group(['namespace'=>'Admin'],function(){
Route::controller("admin"=>"AdminController");
})
If I type localhost/test/foo/admin
everything works fine but when I write: localhost/test/admin
just my index page of the site. 如果我键入
localhost/test/foo/admin
一切正常,但是当我写时: localhost/test/admin
只是我站点的索引页。
I don't know whats wrong here, Route problem or .htaccess
redirecting my and I'm not aware of it. 我不知道这里出了什么问题,路由问题或
.htaccess
重定向了我,我也不知道。
Sorry for code misspelling I just wrote what I recall from last night. 抱歉,我拼写错误的代码是我昨晚回忆的内容。
Note:: I have an index file in my root directory my .htaccess
file of my root directory is like below, and I replaced the server.php
file of my root directory with my index.php
file: 注意:我的根目录中有一个索引文件,我的根目录中的
.htaccess
文件如下所示,我用index.php
文件替换了根目录中的server.php
文件:
RewriteEngine On
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
and my .htaccess
file of my public directory is like default. 我的公共目录的
.htaccess
文件就像默认文件一样。
why don't you run (from terminal): 为什么不运行(从终端):
php artisan serve
then test your project at: http://localhost:8000/ instead of: http://localhost/test/ 然后在以下位置测试您的项目: http:// localhost:8000 /而不是: http:// localhost / test /
or if you are using apache, add new virtual host 或者,如果您使用的是Apache,则添加新的虚拟主机
升级到Laravel 5.3似乎可以解决路由问题,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.