我的网站是非www ,它在子目录中有wordpress,在根目录和其他子目录中有一些静态的网页
所以应该是
/articles.html 到 / articles /
和
/subdirectory/book.html 到 /子目录/ book /
下面的代码
这是我的.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