Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 如何将搜索结果更改为友好url_Laravel_Forms_Seo - Fatal编程技术网

Laravel 如何将搜索结果更改为友好url

Laravel 如何将搜索结果更改为友好url,laravel,forms,seo,Laravel,Forms,Seo,如何更改提交表单时生成的此URL http://localhost:8000/list_entreprise?activity=3&sub_category=1&secteur=1&page=2 要访问此URL,请执行以下操作: http://localhost:8000/list_entreprise/category_name/sub_category_name/secteur_name/2 需要使URL对搜索引擎更友好 我从中的表单中的选择字段中获取类别、子类别

如何更改提交表单时生成的此URL

http://localhost:8000/list_entreprise?activity=3&sub_category=1&secteur=1&page=2
要访问此URL,请执行以下操作:

http://localhost:8000/list_entreprise/category_name/sub_category_name/secteur_name/2
需要使URL对搜索引擎更友好

我从中的表单中的选择字段中获取类别子类别扇区

http://localhost:8000/list_entreprise
我的路线:

Route::get('/list_entreprise','App\Http\Controllers\SiteController@search')->name('search');

您需要在管线定义中指定这些组件

Route::get('/list_enterprise/{list_enterprise}/{category_name}/{sub_category_name}/{secteur_name}/{page?}',App\Http\Controllers\SiteController@search')->name('搜索')

然后确保将这些作为参数添加到
SiteController
中的
search
方法中,即

公共函数搜索($listenerprise,$categoryName,$subCategoryName,$secteurName,$page=null){}

请注意
页面
参数后的“?”,这表示它是URL的可选组件

在这里查看文档


当您为表单的操作指定路由时,您现在需要添加这些参数,以便它可以为您建立URL。

抱歉,这并不能真正回答您的问题。要从选择框将这些值替换到表单提交中,您需要一个JavaScript解决方案,从表单中获取值并将其替换到表单提交到的URL中。不起作用@Andy[缺少[Route:search]的必需参数],但谢谢,你知道我如何使用Javascripor或其他方法来实现它吗