问题描述
我想删除尾部斜杠,以便
https://www.hooklust.com/oo.a/
看起来像
https://www.hooklust.com/oo.a
我找到了以下用于从 URL 中删除尾部斜杠的教程,但我仍然以尾部斜杠结束:
https://www.danielmorell.com/guides/htaccess-SEO/redirects/https-www-and-trailing-slash
代码:
#### Force HTTPS://WWW and remove trailing / from files ####
## Turn on rewrite engine
RewriteEngine on
# Remove trailing slash from non-filepath urls
RewriteCond %{REQUEST_URI} /(.+)/$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ https://www.example.com/%1 [R=301,L]
# Include trailing slash on directory
RewriteCond %{REQUEST_URI} !(.+)/$
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+)$ https://www.example.com/$1/ [R=301,L]
# Force HTTPS and WWW
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [OR,NC]
RewriteCond %{https} off
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
我从 htaccess 文件中取出了所有其他内容,以确保没有其他内容添加斜杠,但仍然是相同的内容。
为什么斜线还在那里?
谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)