我需要静态页面来接管我正在使用的大部分wordpress站点。为了保存静态页面,我已经创建了一个/static
目录,但是我还需要保持现有博客的可见性。我有以下代码在我的.htaccess
文件:
RewriteEngine On
RewriteRule ^blog index.php [L]
RewriteRule ^20* index.php [L]
RewriteRule ^$ static [L]
去mydomain.com/blog
或mydomain.com/2014/01/blog-post
都工作,但如果我试图去mydomain.com
的URL是重定向到mydomain.com/static
,这不是我想要完成的。
此外,尝试访问任何其他页面,如mydomain.com/about.php
抛出404错误,这使我认为我的重写是完全错误的。基本上,我希望除了博客页面和博客文章之外的所有请求都被重写到/static
您需要在目录的末尾加上一个尾斜杠,否则mod_dir和DirectorySlash
会将浏览器重定向到带有尾斜杠的URL。第三条规则是
RewriteRule ^$ static/ [L]