如何在 laravel 中将 Url 路径从文件路径名更改为另一个名称



路由代码下方的鳍。

Route::get('clientlayout.main.index','InvoiceTicketController@show');
Route::get('clientlayout.main.mydomains','InvoiceTicketController@set');

当我运行这些路由时,我得到的网址为

http://localhost:8000/clientlayout.main.index 和 http://localhost:8000/clientlayout.main.mydomains。

我希望我的 URL 更改如下:http://localhost:8000/index 和 http://localhost:8000/mydomains。

建议我更改路线以解决此问题的解决方案。

Route::get('/index','InvoiceTicketController@show');
Route::get('/mydomains','InvoiceTicketController@set');

对于命名路由,您可以这样使用

 Route::get('/index','InvoiceTicketController@show')->name('clientlayout.main.index');

有关更多详细信息,请关注

https://laravel.com/docs/5.6/routing#named-routes

你应该尝试这条路线。

Route::get('/clientlayout/main/index','InvoiceTicketController@show');
Route::get('/clientlayout/main/mydomains','InvoiceTicketController@set');

网址正在制作

http://localhost:8000/clientlayout/main/index
http://localhost:8000/clientlayout/main/mydomains

或者你应该尝试

Route::get('/index','InvoiceTicketController@show');
Route::get('/mydomains','InvoiceTicketController@set');

然后网址正在制作

http://localhost:8000/index
http://localhost:8000/mydomains

最新更新