Older version of laravel here, 5.7. I have a situation where I have a url like this http://127.0.0.1:8000//
I have a catch all of this
Route::get('{uri}', ['uses'=>'PageController@render'])->where('uri', '(.*)');
The URL that comes into the render
method is ''
.
I'm not quite sure the best way to take http://127.0.0.1:8000// and redirect that to http://127.0.0.1:8000.
.htaccess doesn't seem to let me redirect that either with
Redirect 301 // /
or RewriteRule ^$ /? [L,R=301]
Is there any way to get around this?
thanks!
They are treated as the same resource in the browser. Anyway you can check the request URI on the server and redirect to the root path like this:
Route::get('/', function () {
// check the request URI
if($_SERVER['REQUEST_URI'] !== '/')
{
return redirect('/');
}
# The rest of the code
# ...
});