Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Results 1 to 3 of 3

This is a discussion on Error pages outside of public_html in the Shared & Semi-Dedicated forum
Hello, I have multiple sites on my account, two of them are sites which are placed in subdomains and have a multi-hosted domain. I'd like ...

  1. #1
    JPC Member
    Join Date
    Jul 2004
    Location
    the Netherlands
    Posts
    6

    Error pages outside of public_html

    Hello,

    I have multiple sites on my account, two of them are sites which are placed in subdomains and have a multi-hosted domain. I'd like to have custom error pages for each of those sites. I know how to do this.

    I could place a .htaccess file in the root of each site (for the main site in the 'public_html' folder and for the subdomains 'public_html/subdomain'). What I was wondering is the following. Is it possible to place the custom error pages outside the root? So in the same folder as 'public_html' which would be '/home/username/error_pages'. If so, how do I link to that in the .htaccess file?

    I already tried the following for the custom error pages for a subdomain:
    ErrorDocument 404 ../../error_pages/404.html
    ErrorDocument 404 home/username/error_pages/404.html

    for the custom error pages for the root (public_html) I tried this:
    ErrorDocument 404 ../error_pages/404.html
    ErrorDocument 404 home/username/error_pages/404.html

    None of them worked, do I have to place my error pages in the root? I'd like them to be outside of it and all error pages of every site together in one folder.

    Thanks in advance!

  2. #2
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    Quote Originally Posted by Tuhumury
    ...do I have to place my error pages in the root? I'd like them to be outside of it and all error pages of every site together in one folder.
    Yes and no. Apache looks for error pages based on the DOCUMENT_ROOT (the directory where your site's top-most level pages are stored). In the case of your main site, this is /home/username/public_html and for subdomains and multihosted domains this is /home/username/public_html/subdomainname. Apache won't look any lower than these paths for error pages.

    There is, however, a feature of Unix called a symbolic link. Basically a symlink is a pointer to a file. (For an example, the www "directory" in your home directory is a symlink to your public_html directory.) You can create symlinks in your web-accessible areas to files that are in non-accessible areas and Apache will be able to access the files as if they were inside the DOCUMENT_ROOT. You will however still have a "file" listed in the directory, but this method allows you to keep all of your error messages grouped together for management purposes.

    To create symlinks you'll need SSH access and a bit of Unix experience (changing directories mainly). The syntax of the ln (link) command is as follows:

    Code:
    ln -s <target> <link>
    where target is the existing error file and link is the name of the symlink that you want to create. For example, if you have all of your error pages stored in /home/errors and you want to make main404.html your main site's 404 error page, cd into public_html and issue the following command:

    Code:
    ln -s ../errors/main404.html main404.html
    Then, in your .htaccess file add

    Code:
    ErrorDocument 404 main404.html
    to point Apache at the symlink when an error occurs. When Apache goes to open the symlink it will get the contents of /home/errors/main404.html.

    Hope this helps. Let me know if there is anything you don't understand or if you need additional help.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  3. #3
    || $name ne 'R.Stiltskin'
    Join Date
    Jun 2003
    Location
    Tejas
    Posts
    2,438

    Lightbulb

    I'm a little late to the party but I thought I'd offer an alternative to jason's nice solution.

    I wrote up a utility and posted it for you to peruse. I'm calling it the Multidomain Server Status Code Template and it offers a substitute for creating a universally available response template for server errors. Since you have limited shell access, creating symlinks shouldn't be a problem. However, should that access be denied, you're out of luck. Also, this script is designed to serve the universal template from within your public server space and not beyond it, though you could if you really wanted to.

    It is not particularly optimal to serve web resources from the "backend". Creating symlinks from public space area to the more private space files circumvents this. I've always understood this to be a security issue though I'm not black-hat enough to know exactly how such tactics are dangerous. I should probably do more cracking research to satisfy my ignorance.

    At any rate in your /public_html/ directory, create an error directory:
    /public_html/error/

    Add the error statuscode.tpl template to that directory:
    /public_html/error/statuscode.tpl
    and edit as desired.

    For the domain (and any additional subdomains), install the nph-statuscode.cgi script and set the configuration parameters.

    For the domain (and any additional subdomains), modify the top-level .htaccess file ErrorDocument directive.

    Add the statuscode script CSS stylesheet and tweak as desired. The stylesheet may be a valid URL to any domain/subdomain so you need install it into your uppermost domain (and not each subdomain). Just make sure the /path/to/basic.css is configured properly in the nph-statuscode.cgi script.

    At any rate this is another option though not perfect and certainly a beta. I'll modify it should the mood hit me or should I think of something better. Let me know if this helps you. There are always different ways to skin a cat... here is another.

    Have fun.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •