当我尝试这个时
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>
最佳答案
将您的代码更改为:
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]
关于php - laravel 尾部斜杠重定向到本地主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21735527/