一尘不染

laravel尾部斜杠重定向到本地主机

php

当我尝试这个

http://localhost/Testlaravel/public/users/login

有用。但是当我尝试

http://localhost/Testlaravel/public/users/login/

它将我重定向到

http://localhost/users/login/

知道为什么吗?

这是我的htaccess文件

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

    RewriteEngine On

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

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

阅读 239

收藏
2020-05-29

共1个答案

一尘不染

将代码更改为此:

Options -MultiViews
RewriteEngine On
RewriteBase /Testlaravel/public/

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

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
2020-05-29