Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WordPress>;htaccess>;将目录及其所有子目录重定向到一个目录_Wordpress_.htaccess_Redirect - Fatal编程技术网

WordPress>;htaccess>;将目录及其所有子目录重定向到一个目录

WordPress>;htaccess>;将目录及其所有子目录重定向到一个目录,wordpress,.htaccess,redirect,Wordpress,.htaccess,Redirect,在wordpress的htaccess文件中,是否可以使用一个重定向规则将目录及其所有子目录重定向到另一个位置 e、 g 把他们都搬到 http://example.com/new -- 当我尝试这个的时候 RedirectMatch 301 ^/old/(.*)$ /new/ 指着 http://example.com/old/foo/bar 结果是 http://example.com/new/bar 您可以将此规则放在htaccess中(在Wordpress'主规则之前,在行上的

在wordpress的htaccess文件中,是否可以使用一个重定向规则将目录及其所有子目录重定向到另一个位置

e、 g

把他们都搬到

http://example.com/new
--

当我尝试这个的时候

RedirectMatch 301 ^/old/(.*)$ /new/
指着

http://example.com/old/foo/bar 
结果是

http://example.com/new/bar

您可以将此规则放在htaccess中(Wordpress'主规则之前,在行上的重写引擎之后)

注意:您可能必须清除浏览器缓存,因为旧规则已存储在其中

http://example.com/new/bar
RewriteRule ^old(/.*)?$ /new [R=301,L]