0

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?

paulo77
  • 101
  • 1
  • The `ErrorDocument` path is relative to your `DocumentRoot`, which should be pointed to the `public` folder. – ceejayoz Oct 07 '22 at 19:46
  • @ceejayoz I don't understand? Can you give a brief code example? – paulo77 Oct 07 '22 at 20:40
  • Find your server configuration's `DocumentRoot` value. That's where `ErrorDocument` starts looking. – ceejayoz Oct 07 '22 at 21:02
  • @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? – paulo77 Oct 07 '22 at 21:36

0 Answers0