Web Hosting Forums

Results 1 to 13 of 13

This is a discussion on custom error pages and CSS in the Hosting Talk & Chit-chat forum
I've created myself some custom error pages, but the stylesheet i've created for them doesn't seem to be taking effect. Do stylesheets work with custom ...

  1. #1
    Loyal Client
    Join Date
    Mar 2002
    Posts
    77

    custom error pages and CSS

    I've created myself some custom error pages, but the stylesheet i've created for them doesn't seem to be taking effect. Do stylesheets work with custom error pages?

  2. #2
    hell no, we won't go!
    Join Date
    Sep 2002
    Posts
    1,093

    Re: custom error pages and CSS

    Originally posted by katharina
    Do stylesheets work with custom error pages?
    There shouldn't be any problem. Could you paste your code here so that we can see what's happening? Thanks!
    - Colin

    I like food.

  3. #3
    Loyal Client
    Join Date
    Mar 2002
    Posts
    77
    well, the stylesheets sorta work, and sorta don't. If you directly view my custom error page here it looks fine and the stylesheet is applied. However, if I do something that requires an error page to be displayed as a result of an action (i.e. going to this page and just clicking 'cancel' or 'ok' until you get the error page), the stylesheet is not applied.

    let me know if you need to see the stylesheet code as well, tho i'm pretty sure it's not the problem. it's the same stylesheet i'm using elsewhere, and it works just fine.

  4. #4
    Loyal Client
    Join Date
    Oct 2002
    Location
    Southern California
    Posts
    111
    OK, I think I can help... I did my first custom 404 page just a couple of weeks ago.

    The custom 404 page seems to think it is based in whatever subdirectory it was executed from. In other words, if the file that couldn't be found was:

    www.xyz.com/photos/file.htm

    Then when the custom page executes, it will be as if the custom 404 page was actaully located in the www.xyz.com/photos subdirectory.

    SOOOO, what you need to do is make sure that all links from this page are absolute, rather than relative. This applies to images and style sheets, etc.

    Judd

  5. #5
    hell no, we won't go!
    Join Date
    Sep 2002
    Posts
    1,093
    I wasn't able to replicate the problem, but try changing
    Code:
    <link HREF='db/databasestyle.css' REL='stylesheet' TYPE='text/css'>
    to
    Code:
    <link HREF='/db/databasestyle.css' REL='stylesheet' TYPE='text/css'>
    - Colin

    I like food.

  6. #6
    Kubla Khan lookout's Avatar
    Join Date
    Aug 2002
    Location
    Orodruin
    Posts
    1,377
    Style sheets should work with custom error pages. I know mine do. Dogma and jspittler make good points on the relative/absolute pathname stuff.

    A base tag before the link tag might be useful here in each of your error pages, like so:

    <base href="http://www.yourdomain.com/" target="_top">
    <link href='db/databasestyle.css' rel='stylesheet' TYPE='text/css'>

    That will let you use relative pathnames (those without the leading "/") within your error pages, without having to worry about where the heck they've been called from.

    Another thing that may be at play here is how you're calling the error pages in your .htaccess file. I personally don't like to put them in the root folder (kind of messy file management, IMHO). If you place them in some other folder than the root, like /myfolder/myerror, you would need some lines in the .htaccess file like these, depending on which error conditions you use:

    ErrorDocument 400 /myfolder/myerror/400.shtml
    ErrorDocument 401 /myfolder/myerror/401.shtml
    ErrorDocument 403 /myfolder/myerror/403.shtml
    ErrorDocument 404 /myfolder/myerror/404.shtml
    ErrorDocument 500 /myfolder/myerror/500.shtml

    Note that all are absolute paths, i.e. they start with a "/" (the top of the folder structure).
    The trouble with our times is that the future is not what it used to be.
    - Paul Valery

  7. #7
    Loyal Client
    Join Date
    Mar 2002
    Posts
    77
    Thanks for all of the responses guys! I've fiddled around with things, and still haven't gotten it to read my stylesheets. Maybe the problem is that i created my error pages using the cpanel. My .htaccess in my root directory (/www) is blank, and the .htaccess in my dir where my error pages are being served (/www/db) has some previous setting i placed in it, but nothing about error pages. maybe this is the problem? Though i would think if it was, my custom error pages wouldn't be displayed at all...

  8. #8
    Kubla Khan lookout's Avatar
    Join Date
    Aug 2002
    Location
    Orodruin
    Posts
    1,377
    I couldn't get the cpanel error page thingy to work myself, so I just created my own error pages using conventional web page editing tools. I've heard others here have had similar problems.

    I wouldn't think they would work at all without the appropriate lines in an .htaccess file in your public html (www or root) folder. But perhaps there's a default action at play here. Putting the lines in a .htaccess file in the root folder should make sure that the right files will be found when needed.

    Just in case you don't know this, you can make your own .htaccess file yourself easily with an ASCII text editor (like notepad, if you're in windows). Remember that files beginning with a period are usually hidden from normal folder listings (except when using cpanel's file manager). You may need to adjust your ftp client settings to have them appear when listing files.
    The trouble with our times is that the future is not what it used to be.
    - Paul Valery

  9. #9
    Loyal Client
    Join Date
    Mar 2002
    Posts
    77
    Turns out the problem wasn't my .htaccess files (i originally created them using cpanel, but edited on the server using vi.. no time consuming FTP for me! )

    The problem was that the dir i had the stylesheet in is password protected and IP protected. Apparently, the stylesheet couldn't be read, so I just copied it, and moved it into the root dir. Now my error pages read the stylesheets just fine!

    Thanks for all your help guys!

  10. #10
    Loyal Client
    Join Date
    Mar 2002
    Posts
    77
    slight revision (in case anyone else runs into the same problem)....

    i actually had to add the line lookout mentioned (after changing www.yourdomain.com to my actual domain name, of course):
    <base href="http://www.yourdomain.com/" target="_top">

    AND move the stylesheet for it to work. So my final HTML looks like this:

    <title>Database Interface</title>
    <base href="http://www.yourdomain.com/" target="_top">
    <link href="databasestyle.css" rel="stylesheet" type="text/css">

    I hope that helps someone else!

  11. #11
    Kubla Khan lookout's Avatar
    Join Date
    Aug 2002
    Location
    Orodruin
    Posts
    1,377
    Gotta be careful there with those file permissions. VI, huh? Whatever works for you. Glad it's running now. Don't forget to check it from various real and dummy subfolders using different filenames.

    BTW, I did a quick check on the default action for error pages. If you leave your error pages in the root folder and leave the filenames that cpanel generates for them alone, a default action kicks in. That means you don't need your own .htaccess file in that condition. If you want to move them elsewhere (or change their names), that's when you need the .htaccess file to properly direct requests. Jkeller makes a reference to that in this post from a little while back.
    The trouble with our times is that the future is not what it used to be.
    - Paul Valery

  12. #12
    Loyal Client
    Join Date
    Mar 2002
    Posts
    77
    That would explain why my custom pages work even though my .htaccess is blank! Thanks for the info!

    when you mentioned file permissions, i got curious... the dir is actually password and IP protected via .htaccess. The permissions for the dir are just as any other dir. I assume the same problem would occur if the file permissions denied read access tho

  13. #13
    Kubla Khan lookout's Avatar
    Join Date
    Aug 2002
    Location
    Orodruin
    Posts
    1,377
    That's sounds reasonable to me. I'm betting the password protection is getting in the way. You might test it by putting the style sheet (with permissions of 644) in a non-password protected folder (755) to see.

    Sometimes a little experimentation is the quickest way to find stuff like that out.
    The trouble with our times is that the future is not what it used to be.
    - Paul Valery

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
  •