Hello @odedta
Thank you for contacting the support.
Sub-domains are treated as separate domains by WordPress.
It is like adding a redirection of a different website on a different domain.
You would need to add the redirection using a .htaccess file on landing.example.com or Rank Math (if WordPress is installed there).
Here are a couple of tutorials that should help:
https://www.inmotionhosting.com/support/website/setting-up-a-301-permanent-redirect-via-htaccess/
and
https://css-tricks.com/snippets/htaccess/301-redirects/
Hope that helps. If there’s anything else we can help you with, please let us know. We are here to assist.
Hey,
Oh! I see what you mean, thank you very much for the detailed explanation!
Take care 🙂
Hello @odedta
Glad that helped.
If there’s anything else we can help you with, please let us know. Thank you.
Hmm, I looked at this again and it doesn’t make sense…
I have two WordPress installations, one of the subdomain and one on the main domain, I created that redirect on the subdomain so there is no reason why it shouldn’t work.
Anyway, I solved it by adding a template_redirect action as follows:
function my_template_redirect() {
if( is_front_page() ) {
wp_redirect('https://example.com');
die;
}
}
add_action( 'template_redirect', 'my_template_redirect' );
You should try to reproduce the issue on your end to figure this one out, if you can’t reproduce I can share details to my website.
Thanks
-
This reply was modified 5 years, 11 months ago by
Oded Talmon.
-
This reply was modified 5 years, 11 months ago by
Oded Talmon.
Hello @odedta
We stand corrected. The Rank Math plugin does not allow redirecting the homepage as of now.
With that being said, there are existing feature requests, so we’ve added your vote to our internal suggestions lists. If your suggestions are something that we’re able to introduce, we’ll be sure to let you know.
You can redirect using a .htaccess file by adding the following line:
Redirect 301 / http://www.newdomain.com/
Hope that helps. Thank you.
Thank you! keep up the good work 🙂