从站点中的所有 URL 中删除尾部斜杠 [英] Removing trailing slash from ALL URLs in site

查看:47
本文介绍了从站点中的所有 URL 中删除尾部斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对整个 .htaccess 有点陌生,我一直在尝试修改它,以便我的所有链接都不会在其各自 URL 的末尾带有斜杠.我的网站是 filmblurb.org.

I'm kind of new to the whole .htaccess thing and I've been trying to modify it so that none of my links will have trailing slashes at the end of their respective URLs. My website is filmblurb.org.

Wordpress 开始和结束的 .htaccess 代码如下所示:

The code for the .htaccess where Wordpress begins and ends looks like this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

如果有人能引导我朝着正确的方向解决这个问题,我将不胜感激.谢谢.

I would appreciate it if someone can lead me in the right direction on how to fix this. Thanks.

推荐答案

您可以添加一个 RewriteRule 来消除尾部斜杠:

You can add a RewriteRule to eliminate the trailing slash:

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

这篇关于从站点中的所有 URL 中删除尾部斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆