I have a very odd problem here: I have just added a page to an existing site and although obviously published (checkbox ticked, also shown published in the db) the site redirects to the main page as if the site doesn’t exist.
I have no clue why this is happening, also nothing in the error log. Any advice appreciated!
I fixed it by creating the same page again as a new resource. Everything works as expected now. Still wondering how things like this can happen
Glad you got it working. Out of curiosity, how did you create the resource the first time? Is redirecting to the home page normal 404 behavior on this site? If so, are you sure it was a 404 that triggered the redirect?
By cllicking the “+” icon next to the container resource it should be created in.
I think so, atleast that’s what usually happens, when I try visiting a site which is not published. And no, I’m not sure about that one. Is there a way to see this?
In your browser’s dev tools, on the Network tab, you can find the status code of any request. Make sure the filter is either showing all or showing documents. In Chrome the whole row will be red if it’s 404. In Firefox the status code will be purple for some reason.
MODX defaults to using the home page as the 404 page because, after a fresh install, it’s the only page. But it’s a good practice to create a page specifically for 404 errors, partly for your own benefit in situations like this, but mainly to avoid confusing users. Just my two cents on that.
If the problem is fixed now then I guess at this point you can’t test it to see unless you’re curious enough to try to recreate it. I suspect that the page may have been using the home page template so it only appeared to be redirecting to the home page. When you create a new resource from the resource tree it defaults to its parent’s template. So if the container resource you clicked the “+” on was the home page it would have adopted the home page template and perhaps gone unnoticed.
If the page was really 404 though and the path and publish status were all correct then something else is going on.
Thanks for your insights! I might had a feeling I could use that site later to check on anything if somebody here would be interested enough (like you are) to solve this, so I didn’t delete the page yet and just checked on what you mentioned there.
The template is definitely right, so it was not the homepage template causing this.
In the dev tools I don’t get a 404, but I get a 401 unauthorized. Why would that be?
Sounds like you don’t have permission to view that page. There’s a variety of ways access to pages can be restricted. If it’s only this one page having the issue then check if the page is in any resource groups and if so how they might be connected to user groups.
Here’s some related information that may or may not be helpful:
I checked the resource groups as well, but that wasn’t it. Like I said, the resource I created after this worked just fine. One thing I can think of maybe I was in the middle of a core/cache delete through FTP and maybe that wasn’t done when I created the new resource? Not sure…
Thank you for your time and ideas though @dev_willis! Will put this one to the files for now.