I want to configure X-HS-Reason, when I access a url that does not exist, it will return to a 404 page and I want to configure X-HS-Reason to no longer display the slug of the current page.
Hey @09747
Is your question, when a user visits a page with slug that does not exist:
- do not display the slug in the URL in the address bar and show the 404 page?
- redirect the user to the parent page.
For example: domain.com/parent-path/guideakf6k5228/ => domain.com/parent-path/
For case 1:
- use the history API to push changes to the URL without reloading/refreshing
- I would strongly advise against doing this!
For case 2:
- you can use http/meta redirects
- because HubL is rendered server side it can be used to handle your redirection logic, dynamically rendering a meta tag with a redirect property
Either way I do not think you can configure that header.
Hope I’ve answered the correct question and this gets you moving!
If you have any further questions please don’t hesitate to reach out.
Hi @Kevin-C , thank you for your reply, but there seems to be some confusion here, actually, I just want to configure X-HS-Reason, because when I access some 404 pages, X-HS-Reason is set. is No view mapper found to handle request, and some pages are set to have the slug displayed, and displaying this slug caused me to receive a security warning from Pentest. So I want to find out why X-HS-Reason is set differently and how to configure it yourself.
Oh I think I may understand, or be closer to understanding!
Let me reiterate my understanding:
- When you access domain.com/parent-path-a/guideakf6k5228
- you get the X-HS-Reason: “Object for slug…”
- But when you access say domain.com/parent-path-b/x
- you get the X-HS-Reason: “No view mapper found to handle request”
You’re wanting to know why they’re different and how you can configure them manually?
If I am now understanding correctly, we might be able to safely assume your URL “domain.com/parent-path-a/guideakf6k5228” is a dynamically generated page and the URL “domain.com/parent-path-b/x” is not. This I am 84% confident might account for the different X-HS-Reason that you’re seeing.
Now assuming that is also correct your means of “configuring” might be:
- Use the URL Redirects provided by HubSpot
- Publish a page on the “domain.com/parent-path-b/x” URL
- create an object/hubdb for domain.com/parent-path-a/guideakf6k5228 with the property used as the slug for “guideakf6k5228”
I do not believe there to be a programatic way to configure those outside of the redirect route.
Hopefully my assumptions are at least inline and this gets you moving in the right direction!
If you have any further questions please don’t hesitate to reach out.
Hi @Kevin-C, thanks for your reply, but it actually seems like there’s some confusion here. As far as I can tell, the main reason I’m getting the X-HS-Reason “Object for slug…” is because when I access a URL like domain.com/tag/nametag. If the nametag doesn’t exist, I’ll get “Object for slug “nametag”” in the 404 page, while if I access any page that doesn’t exist, it will return X-HS-Reason: “No view mapper found to handle the request”. How i can resolve it

