Score:0

Full URL Required for 404 Page To Work — Apache

pl flag

On a project I'm working on (currently on localhost on MAMP), the 404 page only works if I include the full URL with the ErrorDocument statement in the .htaccess file:

ErrorDocument 404 http://localhost:8888/project/public/404.php

I would like it so that I don't have to manually change this code as and when the site is uploaded from my localhost set up to a live server.

Because the 404 page sits at the same level as the .htaccess file in the public folder I thought I could use:

ErrorDocument 404 404.php

But this does not work, and instead just prints 404.php to the screen when a 404 page should be used.

The folder structure is below, and project is the root folder for the site.

project
— publicFolder
— privateFolder

How do I point the site to the 404.php page, without including the full URL, or in a way that will not need changing then the site is uploaded?

vn flag
The `ErrorDocument` path is relative to your `DocumentRoot`, which should be pointed to the `public` folder.
paulo77 avatar
pl flag
@ceejayoz I don't understand? Can you give a brief code example?
vn flag
Find your server configuration's `DocumentRoot` value. That's where `ErrorDocument` starts looking.
paulo77 avatar
pl flag
@ceejayoz I'm using MAMP, and I believe my DocumentRoot is Applications ▹ MAMP ▹ htdocs. On that basis how do I point that to the `public` folder?
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.