Home
Support Forums

200 status not working

netlify site name: denver-paid-search.netlify.app
how my subdomains are setup:
image

I’m building a site with content coming from contentful. I have it building out 4 pages and have 4 subdomains setup in netlify. I’m trying to get each subdomain to redirect to its respective page that gatsby builds (i.e. /your-calling) but I want it to show like it’s at the subdirectory root… like the ‘your-calling’ page is the index page.

In the root of my project I have this for my netlify.toml

[[redirects]]
  from = "https://denver-paid-search.netlify.app/*"
  to = "https://experience.du.edu/:splat"
  status = 301
  force = true

# for all general pages
[[redirects]]
    from = "https://experience.du.edu/"
    to = "https://experience.du.edu/experience"
    status = 301
    force = true

# for all business pages
[[redirects]]
    from = "https://your-calling.du.edu"
    to = "https://your-calling.du.edu/your-calling"
    status = 200
    force = true
# engineering pages
[[redirects]]
    from = "https://innovate.du.edu"
    to = "https://innovate.du.edu/innovate"
    status = 301
    force = true

# biology pages
[[redirects]]
    from = "https://discover.du.edu"
    to = "https://discover.du.edu/discover"
    status = 301
    force = true

Everything is redirecting correctly, meaning, when a visitor goes to https://your-calling.du.edu it shows the ‘your-calling’ page correctly, but the url ends up being https://your-calling.du.edu/your-calling (I want to the user to only see https://your-calling.du.edu). Now, it doesn’t matter if I use 200 or 301 (see how I have your-calling as 200 and the others as 301… that is to test), it always redirects to show the page name.

What am I doing wrong? How can I get it so that whichever of these 4 urls get hit, that it stays at the subdomain and still shows the correct page without showing the page name in the url?

Thanks!

Hi @b00y0h

Indeed, when visiting https://your-calling.du.edu I see https://your-calling.du.edu/your-calling in the address bar.

I also see this in the source. (formatting mine)

<script id="gatsby-script-loader">
/*<![CDATA[*/window.pagePath="/your-calling";/*]]>*/
</script>

I know very little of gatsby, but seems gatsby is the one modifying the path.

1 Like

Every page on the site, even ones in the ‘Pages’ directory has that snippet. That’s not the same as window.location. It’s also commented out.

Commented out for validation per here so it doesn’t break browsers that don’t understand it.

Also see 6. Inject Page Info to CDATA / First load for more on the CDATA.