[英]how should i change a route to make it find routes by dotes “.”?
I'm doing a project that the tutorial that I'm learning from, has not the same LARAVEL version as the mine. 我正在做一个项目,该项目是我正在学习的教程,其版本与我的LARAVEL版本不同。 so it keeps routing the controllers with dots but doesn't make any changes to the routing page codes. 因此它始终用点来路由控制器,但不对路由页面代码进行任何更改。 like setting or changing the rout name or something like that and for that version it worked fine. 例如设置或更改溃败名称或类似名称,对于该版本,它可以正常工作。 but in my project, server can't recognize that kind of routing. 但是在我的项目中,服务器无法识别这种路由。 how should i change the routes to work correctly? 我应该如何更改路线才能正常工作?
i know for those kind of routes that we add them we can set a name for them to find the route correctly but I need to set the /home
route in a way that will work fine but it doesn't matter where do i add the dot in the name of route, .home or home. 我知道对于我们添加它们的那些路由,我们可以为它们设置一个名称以正确找到路由,但是我需要以一种可以正常工作的方式设置/home
路由,但是我在哪里添加都没关系路线名称( .home或home)中的点。 , it won't work! ,将无法正常工作!
here is my web.php code: Route::get('/home', 'HomeController@index')->name('home');
这是我的web.php代码: Route::get('/home', 'HomeController@index')->name('home');
and my controller : 和我的控制器 :
public function index()
{
return View('index.index');
}
localhost:8000/home works fine but i need to fix localhost:8000 routing to be recogniz 本地主机:8000 / home工作正常,但我需要修复本地主机:8000路由才能识别
it's unclear what you're asking. 不清楚你在问什么。
You've made an url for /home
which is named home
. 您已经为/home
了一个名为home
的URL。 This means that in your blade templates, you can call 这意味着您可以在刀片模板中调用
<a href="{{ route('home') }}">
The dot can be used as a separation symbol, Naming the route home.index
usually means: home controller, index method. 点可以用作分隔符号,命名路线home.index
通常意味着:home控制器,索引方法。 It can be whatever you like though. 可以随便你。
So you likely want to change the route name to ->name('home.index')
因此,您可能希望将路由名称更改为->name('home.index')
You could then access that using route('home.index')
然后,您可以使用route('home.index')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.