我将旧的静态站点移动到名为old的子目录。我还在root上安装了WordPress。现在我想为我的旧静态站点实现301重定向。问题是我想将http://www.example.com/x重定向到/ old / x,除非在web根目录中有x(事实上我不想重定向WordPress文章,页面等)。我试过这个:
# Map http://www.example.com/x to /old/x unless there is a x in the web root.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/old/
RewriteRule ^(.*)$ /old/$1
#WordPress default .htaccess
# BEGIN s2Member GZIP exclusions
<IfModule rewrite_module>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} (^|\?|&)s2member_file_download\=.+ [OR]
RewriteCond %{QUERY_STRING} (^|\?|&)no-gzip\=1
RewriteRule .* - [E=no-gzip:1]
</IfModule>
# END s2Member GZIP exclusions
# 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
它不起作用,我认为存在某种冲突。