在 WordPress 中使用 .htaccess 删除尾部斜杠

编程入门 行业动态 更新时间:2024-10-20 08:22:58
本文介绍了在 WordPress 中使用 .htaccess 删除尾部斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在寻找一种方法来删除所有 WordPress URL 的尾部斜杠.

I'm looking for a way to remove trailing slash for all WordPress URL's.

我找到了类似的答案,例如 这个 但是当之前有 WordPress .htaccess 规则时它不起作用.

I found similar answers like this one but it doesn't work when there's WordPress .htaccess rules before.

这是我当前的 WordPress .htaccess:

Here is my current WordPress .htaccess:

# 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

推荐答案

试试这个:

# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteRule (.+)/$ $1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>

如果它不起作用试试这个:

If it doesn't work try this one:

# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteRule (.+)/$ www.domain/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>

更多推荐

在 WordPress 中使用 .htaccess 删除尾部斜杠

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

发布评论

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

>www.elefans.com

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