从站点中的所有 URL 中删除尾部斜杠

编程入门 行业动态 更新时间:2024-10-24 04:49:21
本文介绍了从站点中的所有 URL 中删除尾部斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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.

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 中删除尾部斜杠

本文发布于:2023-11-01 23:09:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550679.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:斜杠   尾部   站点   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!