admin管理员组文章数量:1122846
I know I can use multi site but what I want to do is different so guide me My country is filtering my domain regularly and since I'm getting all my traffic from google search I need to change domain every time and losing google rank so now I want to do something different to do not lose my google rank I have 2 domains example ( this is my main domain which is google seeing it, should have index and follow meta tags ) example ( this is my second domain that only My country users will use it so can be change ez when got filtered, should have noindex and nofollow meta tags ) I just create a page rule on cloudflare and set a redirect for users from my country to example ( they will see my main domain on google results while searching but when they click it they will redirect to my second domain which is example )
What I did so far ? I've added this code to my wp-config.php
if ($_SERVER['HTTP_HOST'] == 'example') {
define('WP_HOME', '');
define('WP_SITEURL', '');
} else {
define('WP_HOME', '');
define('WP_SITEURL', '');
}
so this part of code is working fine due to rewriting all files and urls with the second domain no my another problem to fix is NoIndexing and NoFollowing my second domain to stop duplicate error on google so I did this since I'm using Rank Math I've added this code to my theme function.php
add_filter('rank_math/frontend/robots', function($robots) {
if ($_SERVER['HTTP_HOST'] === 'example') {
// Return an array to avoid type errors
return ['noindex' => 'noindex', 'nofollow' => 'nofollow'];
}
return $robots;
});
and adde this line in my theme header.php
<?php if ($_SERVER['HTTP_HOST'] == 'example') : ?>
<meta name="robots" content="noindex, nofollow">
<?php endif; ?>
now my whole website is available under two domains , without any url confilit example example and when I check all urls under domain example has index and follow meta tags and all urls under example does have noindex and nofollow meta tags I just wanted to know is it ok to do it ? do I need to anything more? is it enough ?
本文标签: redirectHow to Setup 2 Domains on a Single Wordpress (Regions Filter)
版权声明:本文标题:redirect - How to Setup 2 Domains on a Single Wordpress (Regions Filter)? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736305365a1932564.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论