Reputation: 3117
As search by parameters, I want url display subdir instead parameter like this:
Here params url : search/?genre=a&pref=b&city=c&sticking&=d
And here is subdir url after convert for display: search/a/b/c/d
In the case search url has less than 4 params, it can be converted to some urls like this:
search/a/b/c
search/b/c/d
search/a
search/b
...
Is there any way to use htaccess to do that?
I'm using Laravel.
Thank you for your answer.
Upvotes: 1
Views: 80
Reputation: 1383
In your /route/web.php or /route/api.php file, you can define the route like below:
Route::get('/search/{a?}/{b?}/{c?}/{d?}', 'SearchController@method');
In the controller as suggested by Rian Zaman, you have to do something like this:
public function method_name($a = null, $b = null, $c = null, $d = null)
{
// Your code here ...
}
Upvotes: 2
Reputation: 429
If you want to achieve that I would suggest to use optional route parameters if you know what could be the max number of search term.
You can achieve that by doing the following,
In your route:
Route::get('/your-route/{param1?}/{param2?}/{param3?}/{param4?}');
In your controller:
public function function_name($param1 = null, $param2 = null, $param3 = null, $param4 = null){
// your logic
}
Please follow the link for reference: Optional parameters
Upvotes: 1