I created a Laravel project under mywebsite.com/laravel/. When I go to mywebsite.com/laravel/test, everything is fine, but when I go to mywebsite.com/laravel/test/, I am redirected to mywebsite.com/test.
I have index.php and .htaccess files in the / laravel directory. This is my .htaccess file:
<IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On # Redirect Trailing Slashes If Not A Folder... RewriteBase /laravel RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L]
I have no idea why RewriteBase not working. I tried / laravel, / laravel / and laravel; nothing worked.
My route.php file
<?php Route::get('/test/{name?}', 'MainController@index'); Route::group(['middleware' => ['web']], function () {
php laravel
user5222939
source share