Support Forums

Headless WordPress on Subdomain


I am trying to wrap my head around a headless wordpress setup with the frontend hosted on Netlify. I have my custom domain set to use Netlify’s DNS. Do I only have to point an A record to the IP address of the server where the WordPress install is hosted? Am I supposed to point a CNAME record as well?

Hey @ck9891, I think you’ll want to look into this post/video that talks about what’s involved in setting up headless Wordpress with Netlify:

You’ll need to pull your Wordpress data into a static site generator and deploy that static site on Netlify.

If you’ve done that already, we’d be happy to help you set up your DNS records on the Netlify side- let us know!

Hi Jen, I’ve already deployed a Gatsby frontend with Netlify at the root domain. The root domain was registered through GoDaddy, but I’ve set it to Netlify’s name servers.

I’m looking to be able to point the sub-domain, or sub-domains, to the actual WordPress install so I can access the admin panel and have sub-sites living on the sub-domain.

You should be able to do this on the Netlify DNS settings page for this site. Keep in mind that you will also have to change the name of the site in WordPress to reflect the fact that it is running as a non-www subdomain, or else your WordPress instance will lock up tight as a drum. If that happens, you will have to go in with phpMyAdmin (or the equivalent) and update the subdomain name in the MySQL database.

Alternatively, assuming you have WordPress running on a host somewhere where it has an internal “non-custom” domain (such as yoursite.wpengine.com), just use that assigned domain name, as there should be no one but you visiting it.

@jen that video’s great, but doesn’t explain the DNS-side of things which was the original question posted by @ck9891

I’m curious as well.

I want to host the Wordpress install at Digital Ocean on a subdomain of mydomain.com. So, https://sub.mydomain.com. Then, I want my public-facing site served via Netlify at https://mydomain.com.

I’ve only had success when the Wordpress install is hosted at a totally different domain (https://totallydifferentdomain.com).

Hi, @djmtype. Let’s say you have a static public IP address at DigitalOcean of (yes, “ten-dots” are not public IP addresses - but let’s pretend).

If you want sub.mydomain.com to point to that IP address, you would make an A record for that name and IP address which would look something like this when queried:

sub.mydomain.com.   1800	IN	A

You might instead have a domain name and not an IP address to point to.

Let’s say the Wordpress install is at wordpress.example.com and you want to use that name instead of the IP address. If so, you would make a CNAME record instead:

sub.mydomain.com.   1800	IN	CNAME  wordpress.example.com.

Note, if you want to connect via HTTPS/SSL, you will need to install an SSL certificate on the Wordpress instance itself.

SSL is handled via HTTP not DNS. This means that the web server you point to (the Wordpress host) must provide the SSL for that subdomain.

If there are other questions about this, please let us know.

1 Like

Luke, I really appreciate your response. I had chosen the IP route since Digital Ocean gives you a static public address, and applied an SSL to the subdomain. I then set up an A record like you’ve illustrated above. I created a _redirects file in my Gridsome project for the wp-admin and wp-json routes, too.

That’s also nice to know how to handle it when the WP install lives at a different domain using a CNAME.

1 Like