Special domain for a page

时间:2019-10-21 作者:Fanky

我有一个wp安装example.com 并且想要secondary.com 显示的内容example.com/b (b是一页)但保留secondary.com 在url中(非secondary.com/b)

我尝试了这种方法:https://stackoverflow.com/a/35272993/2095642

我将两个域都指向一个目录,我在wp-config.php:

//this works, enables both domains to show the same wp installation
define(\'WP_SITEURL\', \'http://\' . $_SERVER[\'HTTP_HOST\']);
define(\'WP_HOME\', \'http://\' . $_SERVER[\'HTTP_HOST\']);
这是我的。htaccess:

#this works, changes example.com/b url to secondary.com
RewriteCond %{HTTP_HOST} example.com$
RewriteRule ^b/(.*)$ https://www.secondary.com/$1 [L,QSA,R=302]

#this doesn\'t take effect and shows homepage on secondary.com
#I want it to keep only secondary.com in URL but show page /b/.
RewriteCond %{HTTP_HOST} secondary.com/?$
RewriteRule ^$ /b/ [L,QSA]
第二条规则在指向非wp目录时正常工作-保留url但显示目录的索引。但当指向wp页面路径时,它不会。

谢谢

1 个回复
SO网友:Fanky

有一个插件可以做到这一点:

https://wordpress.org/plugins/multiple-domain-mapping-on-single-site

无论如何,用几行可以理解的脚本来控制事情会更好,所以我仍然对答案持开放态度