Wordpress htaccess从子目录中构建的站点重定向

Wordpress htaccess从子目录中构建的站点重定向,wordpress,.htaccess,mod-rewrite,redirect,url-redirection,Wordpress,.htaccess,Mod Rewrite,Redirect,Url Redirection,这似乎是一种罕见的情况,因为到目前为止我还没有找到它的线索 我在一个子目录中建立了一个wordpress网站(例如example.com/subdir/是主页) 我现在正在同一个域上构建一个新站点来替换example.com/subdir/,它将位于example.com的根目录中 我需要301将example.com/subdir/folder1/下的所有页面重定向到example.com/newfolder上的一个页面/ 我没有太多的htaccess经验,但我希望下面的htaccess文件能

这似乎是一种罕见的情况,因为到目前为止我还没有找到它的线索

我在一个子目录中建立了一个wordpress网站(例如example.com/subdir/是主页)

我现在正在同一个域上构建一个新站点来替换example.com/subdir/,它将位于example.com的根目录中

我需要301将example.com/subdir/folder1/下的所有页面重定向到example.com/newfolder上的一个页面/

我没有太多的htaccess经验,但我希望下面的htaccess文件能够工作(我将它放在example.com/subdir/目录中)。但是,它仍然允许我访问example.com/subdir/folder1/及其下的所有页面,而无需将我重定向到example.com/newfolder/

我做错了什么

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subdir/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subdir/index.php [L]

RedirectMatch 301 ^/folder1(.*)$ http://example.com/newfolder/
</IfModule>

重新启动发动机
重写基/子磁盘/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/subdir/index.php[L]
重定向匹配301^/folder1(.*)$http://example.com/newfolder/

我还用Redirect 301命令代替RedirectMatch 301进行了尝试,没有骰子。

在其他WP规则之前有301规则:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subdir/

RewriteRule ^folder1(.*)$ http://example.com/newfolder/ [L,R=301]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subdir/index.php [L]

</IfModule>

重新启动发动机
重写基/子磁盘/
重写规则^folder1(.*)$http://example.com/newfolder/ [L,R=301]
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/subdir/index.php[L]

谢谢,成功了。处理1对1重定向的最佳方式是什么?如果我需要example.com/subdir/page3/重定向到example.com/page6/我会使用RewriteRule page3/?