Report this

What is the reason for this report?

What is the php path for an Ubuntu 14.04 droplet?

Posted on January 21, 2016

Good day everyone,

I was wondering if you could tell me how I could make this line work in my htaccess (both versions):

ErrorDocument 404 /apps/{NAME}/public/404.php
ErrorDocument 404 /404.php

Basically the 404 is in my /public folder (root directory) and that’s what I’d like to link to in the .htaccess. I’ve tried searching the topics here and I can’t figure out what exactly I’m asking for. The “php path” sounds like the best bet? Lol. ;-)



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello there!

That sounds about right or that you are on the right track. If it does not work, the problem may lie in how you are handling your general .php requests (catch-all vs. specific php files). If you are just handling “index.php”, the redirect to handle your new php error page might not be served properly.

Hope this helps! :)

Hi @GreenKi,

If you haven’t seen this already, ServerPilot has an article on customizing Apache error messages.

This format does work:

ErrorDocument 404 /404.php

assuming you have a file called “404.php” in your app’s “public” directory.

Note that you can’t use the ErrorDocument directive to catch 404’s for requests that end in “.php” themselves. That is, if a file is requested such as “/this-does-not-exists.php”, that won’t get handled by the ErrorDocument directive because the request ends in “.php”. To handle 404s for requests that end in “.php”, you should use rewrite rules that direct those requests to a specific php script which can send a 404 response.

For example, adding this in your .htaccess file will show a custom 404 page (using a file named “404.php”) for requests for php scripts when the requested script doesn’t exist:

RewriteRule ^404\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /404.php [L]

Then in that 404.php script you would have something like:

<?php
header("HTTP/1.0 404 Not Found");
// generate the HTML of the response here
?>

If you’re still having problems with this, you can open a ticket with ServerPilot.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.