Laravel 5:当网址以“/”结尾时防止重定向[重复]

时间:2022-10-20 10:36:45

This question already has an answer here:

这个问题在这里已有答案:

My application url is:

我的申请网址是:

http://localhost/my-app

And my admin panel is here:

我的管理面板在这里:

http://localhost/my-app/admin

But when I try to access the admin panel using this url:

但是当我尝试使用此URL访问管理面板时:

http://localhost/my-app/admin/

It redirects me to :

它将我重定向到:

http://localhost/admin

Is there any way to prevent this by happening? I want to access the admin panel from this url also.

有没有办法防止这种情况发生?我也想从这个URL访问管理面板。

My htaccess file looks like this currently:

我的htaccess文件目前看起来像这样:

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

    RewriteEngine On

    # 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>

1 个解决方案

#1


0  

I cannot give comment, so i'll try here instead.

我不能发表评论,所以我会在这里试试。

you need to remove this line from .htaccess

你需要从.htaccess中删除这一行

RewriteRule ^(.*)/$ /$1 [L,R=301]

or add # in front of it to comment.

或在其前面添加#进行评论。

#1


0  

I cannot give comment, so i'll try here instead.

我不能发表评论,所以我会在这里试试。

you need to remove this line from .htaccess

你需要从.htaccess中删除这一行

RewriteRule ^(.*)/$ /$1 [L,R=301]

or add # in front of it to comment.

或在其前面添加#进行评论。