本文介绍了在 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 删除尾部斜杠
发布评论