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