删除.html扩展后添加尾部斜杠

我的网站是非www ,它在子目录中wordpress,根目录其他子目录中有一些静态的网页

  1. 我想从根目录中的网页和其他静态网页子目录中删除.html扩展。
  2. 最后加斜线。
  3. 301使用斜杠从非斜杠redirect到url。

所以应该是

/articles.html / articles /

/subdirectory/book.html /子目录/ book /

下面的代码

  1. 最后用非斜线工作
  2. 使用斜杠将301redirect到非

这是我的.htaccess

<IfModule mod_rewrite.c> Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / #removing trailing slash RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ $1 [R=301,L] #www to non RewriteCond %{HTTP_HOST} ^www\.(([a-z0-9_]+\.)?domain\.com)$ [NC] RewriteRule .? http://%1%{REQUEST_URI} [R=301,L] #html RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^\.]+)$ $1.html [NC,L] #index redirect RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /index\.html\ HTTP/ RewriteRule ^index\.html$ http://domain.com/ [R=301,L] RewriteCond %{THE_REQUEST} \.html RewriteRule ^(.*)\.html$ /$1 [R=301,L] </IfModule> 

PS一切都可以与WordPress的,只有静态页面的问题。

先谢谢了

我似乎无法评论,似乎,但我猜测wordpress有一个单独的.htaccess文件,其中包含额外的规则,以使这些网页的工作。 我猜你的静态页面将需要额外的显式规则,这些可以添加到.htaccess或虚拟主机,但在这两种情况下应该看起来像: RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^staticpage1$ ./staticpage1.html RewriteRule ^staticpage2$ ./staticpage2.html