I'm redesigning old website which is built with custom code, and now we are using Laravel framework (version 5.3). The problem is that old website has all links with trailing slashes. It has great SEO and many visits from search engines so removing trailing slashes is not the option.
In my routes/web.php file i have following routes:
$router->get('texts/', 'TextController@index');
$router->get('texts/{slug}/', 'TextController@category');
$router->post('texts/search/', 'TextController@searchPost');
$router->get('texts/search/', 'TextController@search');
Showing links on html/blade views with trailing slashes is not the problem, problem is redirecting to route links.
App/Http/Controllers/TextController.php
public function searchPost()
{
...
return $this->response->redirectToAction('TextController@search');
}
This redirect me to "texts/search" instead on "texts/search/". Is there any options to turn on/off trailing slashes in Laravel or some hacky way to fix this ? .htaccess redirect is not the solution because it adds one more redirect and slows down website.