Redirecting WordPress blog content to Netlify is not working as intended

Hello All,
I have a primary Reactjs site hosted on Netlify and I have a Wordpress site that is hosted using Elementor.
The Netlify site name is pmg-staging.netlify.app. The blog is on the subdomain of blog.partneredmg.com.

The goal is to have the WP site and its content be redirected to the primary domain with the /blog path.

The below is my current .toml file. I have tried reversing the to and from sites to having my external site be the from site, but when I do that I just get a 404 page when trying to access the blog.

In the code below the issue is that It goes to the /blog site just fine, but when I click on any article it opens the article in a new tab under the subdomain not the new path.

TIA!

[build]
    command = "yarn run build"
    publish = "/build"

[[redirects]]
  from = "/blog"
  to = "https://blog.partneredmg.com"
  status = 200
  force = true

 [[redirects]]
  from = "/blog/* "
  to = "https://blog.partneredmg.com/:splat"
  status = 200
  force = true

[[redirects]]
    from = "/*"
    to = "/index.html"
    status = 200


 
[[headers]]
    for = "/*"
    [headers.values]
        test-it = "true"
        cache-control = "no-cache"

@augdog978 While not what you’re trying to do, it is all working exactly as I’d expect.

The issue:

Is because Netlify’s system only proxies the destination site to the path.
It doesn’t change anything about the content.
It doesn’t have any control over redirects on the other site.

The URL’s on the blog.partneredmg.com site are absolute and have target="_blank" specified.

So they’ll open that URL in a new tab.

@nathanmartin Thank you for the reply!

That makes sense, so using an * and :splat wont work with netlify? Is that what you are saying?
Would removing target_blank have a different affect?

That’s not at all what I’m saying.

The wildcard and splat are provably working.

They’re why this URL:
https://pmg-staging.netlify.app/blog/unlock-your-potential-exploring-top-project-management-training-courses/

Serves the contents of this URL:
https://blog.partneredmg.com/unlock-your-potential-exploring-top-project-management-training-courses/

However you’ll find that when accessing the same page via this URL (with no trailing slash):
https://pmg-staging.netlify.app/blog/unlock-your-potential-exploring-top-project-management-training-courses

That you end up on blog.partneredmg.com
It’s due to a 301 redirect being sent by the Wordpress site.

image

It’s probably related to it enforcing trailing slashes.

Removing the target="_blank" would have the usual effect.
It would mean that the links open with their default behavior.

@nathanmartin Thank you for the information. I am still lost on what I need to do in order to get the functionality im looking for which is having content be served under the /blog URL and not the subdomain.

I tried removing the slah via a custom structure in WP and that did not work.

Thank you for your time and help!

There isn’t anything else to do on Netlify’s side of things.

You need to make appropriate changes to the Wordpress site, so that it matches what you want.

E.g. If the goal is to keep the users on the Netlify site, you could change the links on the Wordpress site.

https://pmg-staging.netlify.app/blog
Loads the page correctly, because the Netlify proxy is working.

But as previously mentioned, the article links on the Wordpress site are absolute, the first one is:
https://blog.partneredmg.com/business-growth-fractional-project-management
So clicking it causes the browser to go to the Wordpress site.

If the article links on the Wordpress site were instead root relative:
/blog/business-growth-fractional-project-management

Clicking it would stay on the Netlify site, and you wouldn’t have a problem:
https://pmg-staging.netlify.app/blog/business-growth-fractional-project-management

I can’t give you specifics for how to modify your Wordpress site though, you’d need to google around or seek assistance for that elsewhere.

@nathanmartin That helps tremendously. Thank you!