URL with trailing slashes gets redirected to local

2019-08-08 19:46发布

问题:

This question already has an answer here:

  • laravel trailing Slashes redirect to localhost 4 answers

The fix in the duplicate question doesn't work.

I tried all the Fixes in stackoverflow but nothing seems to be working laravel trailing Slashes redirect to localhost

Route

Route::get('/admin', array('as' => 'admin', 'uses' => 'Admin\Admin@getLogin'));

This URL is working fine http://localhost/app/admin

but when I add a trailing slash in front of it http://localhost/app/admin/ it gets redirected to http://localhost/admin

Help!

回答1:

Added this and it worked!

RewriteCond %{REQUEST_URI} !^


回答2:

i too had this problem and mine need a combination of the above with suggestions from some other posts. Don't remember from which posts anyways this was my .htaccess that got me working correctly.
And 1 more thing our project did not have public in the url.

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On
    RewriteBase /PROJECT_NAME

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_URI} !^
    RewriteRule ^(.*)/$ $1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>