What is the php path for an Ubuntu 14.04 droplet?

Posted January 21, 2016 7.1k views

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. ;-)

  • I just realized this may be a question for serverpilot…if it is let me know and I’ll shuffle the question over to that website…sorry!

  • What does ps aux | grep php yield?

  • @Rockeer
    I can’t seem to copy and paste from the terminal. (LOL! Learning.) :)

    master process is showing (/etc/php5.4-sp/fpm.conf)
    then near the bottom it says pool {droplet name}

  • This appears to be a part of serverpilot’s features. I’ll go ahead and ask the question over there. I apologize. I’m brand spankin’ new to VPS’s (from CPanel after 6 years lol.)

  • Show 6 more comments

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.

Submit an Answer
2 answers

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:

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.