I have a wordpress multisite with one site to domain.com and another to materials.domain.com

At the domain site I have a page domain.com/materials

I'd like to redirect the materials.domain.com homepage to the domain.com/materials

I'm using a child theme to my subdomain instalation and trying the following on functions.php


Now when I access the materials.domain.com the showed url is https://materials.domain.com/https://domain.com/materials/

What i'm doing wrong? How can I achieve the correct redirection?

  • Welcome to WordPress Development. I hope you find the answer(s) you are looking for (I have added what I think is the answer). Our site is different from most - if you have not done so yet, consider checking out the tour and help center to find out how things work. Commented Jun 6, 2020 at 15:58

2 Answers 2


Have you tried creating the redirect within the CPanel of wherever your website is being hosted from? I manage all of my redirects there, rather than from within my functions.php. There's a really simple guide on doing that here.

Or is there a specific reason that you would like the redirect to be within the functions.php?


The problem is here:


home_url adds the home URL to the start of the link. In your case you get something as if you had gone:

$out = "https://materials.domain.com/" . "https://domain.com/materials/";

Instead, try this:


that will send the user to the link without the part you do not want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.