Laravel 5:带斜杠的URL被重定向到localhost


Laravel 5 : URL with trailing slashes gets redirected to localhost

我可以用http://localhost/rnd/public/coeg-admin访问我的url,但如果我访问http://localhost/rnd/public/coeg-admin/,它会被重定向到http://localhost/coeg-admin

我只是跟随laravel后斜杠重定向到localhost和URL后斜杠重定向到localhost在laravel 5

但它没有像预期的那样工作,这是我的.htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>
    RewriteEngine On
    # Set base URL
    # RewriteBase /rnd/public/
    # RewriteRule ^(.*)/$ /$1 [L,R=301]
    # RewriteCond %{REQUEST_URI} !^
    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]
    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

这是我的apache2.conf

<Directory "/var/www/html/rnd/public">
        Options Indexes FollowSymLinks
        #AllowOverride None
        AllowOverride All
        Require all granted
</Directory>
<Directory "/var/www/html">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

如何,我可以重定向url在结尾有斜杠到url没有斜杠在结尾?

我做的最简单的方法是从公共/.htaccess中删除RewriteRule ^(.*)/$ /$1 [L,R=301]

不要忘记清除缓存,因为chrome重定向缓存也保存在浏览器中