Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/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
Php 将子域所有帖子重定向到主域_Php_Wordpress_.htaccess_Redirect - Fatal编程技术网

Php 将子域所有帖子重定向到主域

Php 将子域所有帖子重定向到主域,php,wordpress,.htaccess,redirect,Php,Wordpress,.htaccess,Redirect,我想将子域上的所有帖子重定向到live domain 例如,www.blog.mydomain1.com/post-1到www.mydomain1.com/post-1 我尝试了这个htaccess代码,它重定向了主子域,但没有重定向post链接 RewriteEngine On RewriteCond %{HTTP_HOST} ^blog\.mydomain1\.com$ [NC] RewriteRule ^(.*) http://www.mydomain1.com/$1 [R=301,

我想将子域上的所有帖子重定向到live domain

例如,www.blog.mydomain1.com/post-1到www.mydomain1.com/post-1

我尝试了这个htaccess代码,它重定向了主子域,但没有重定向post链接

 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^blog\.mydomain1\.com$ [NC]
 RewriteRule ^(.*) http://www.mydomain1.com/$1 [R=301,L]
我的完整访问权限是

# 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

 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^blog\.(.+)$ [NC]
 RewriteRule ^(.*)$ http://www.%1/$1 [NC,R,L]

# BEGIN MainWP
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-content/plugins/mainwp-child/(.*)$ /wp-content/plugins/THIS_PLUGIN_DOES_NOT_EXIST [QSA,L]
</IfModule>

# END MainWP
#开始WordPress
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress
重新启动发动机
重写cond%{HTTP_HOST}^blog\(.+)$[NC]
重写规则^(.*)$http://www.%1/$1[NC,R,L]
#开始MainWP
重新启动发动机
重写基/
重写规则^wp content/plugins/mainwp child/(.*)$/wp content/plugins/此插件不存在[QSA,L]
#结束MainWP

测试此重定向之前,请清除浏览器缓存。

只有www.blog.mydomain1.com重定向到www.mydomain1.com,但此帖子www.blog.mydomain1.com/post-1未重定向到www.mydomain1.com/post-1是否有其他链接重定向?谢谢。是的,blog.mydomain1.com中有300多篇帖子。@Nikunchavda我认为您当前的htaccess设置有问题,您能在问题中发布完整的htaccess吗?我已经发布了blog(子域)htaccess。请检查,如果有任何问题,请告诉我。非常感谢你努力解决我们的问题
 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^blog\.(.+)$ [NC]
 RewriteRule ^(.*)$ http://www.%1/$1 [NC,R,L]