URL with trailing slashes gets redirected to local

2019-08-08 19:44发布

This question already has an answer here:

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!

2条回答
forever°为你锁心
2楼-- · 2019-08-08 20:09

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>
查看更多
Explosion°爆炸
3楼-- · 2019-08-08 20:22

Added this and it worked!

RewriteCond %{REQUEST_URI} !^
查看更多
登录 后发表回答