Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2009
    Posts
    37
    Thanks
    11
    Thanked 1 Time in 1 Post

    404 custom page styling problem

    Hi guys,

    I've set up a custom 404 error page, in case old links are referring to content which has been moved or deleted.

    Now I have a small problem here for which I am not able to find an answer on google. The 404 error page shows correctly in the root with the right styling. But when I am in a sub directory, no styling is used. Just the plain text, which look rather silly. Locally (on my workstation) the 404 pages within directories are styled correctly, but online not.

    To summarise:

    www.test.com/404 shows and works correctly. But add an extra '/', as in www.test.com/wronglink/wronglink2 the 404 error page loses its styling.

    How do I fix that?

    Code .htaccess:
    Code:
    ErrorDocument 404 /404.html
    edit: not sure where to put this thread. So I put into the category where I found the most 404 questions. I apologize if this is the wrong thread.
    Last edited by rogierius; 06-18-2010 at 10:26 AM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Could you post the html source of your 404.html page?
    I think it's something to do with the path of CSS/image files. The use of absolute paths to refer all files from the client side may solve the issue. Take a look at the post at http://www.codingforums.com/showthre...167#post784167
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Aug 2009
    Posts
    37
    Thanks
    11
    Thanked 1 Time in 1 Post
    You mean like this?

    Code:
    <?xml version="1.0" encoding="iso-8859-2"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
    <link rel="shortcut icon" href="images/faviconproducts.ico" type="image/x-icon" />
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
    <title>******* </title>
    <meta http-equiv="Content-Language" content="en" />
    <meta name="description" content="******* " />
    <meta name="keywords" content="******* " />
    <meta name="robots" content="index, follow" />
    <meta http-equiv="Page-Enter" content="revealtrans(duration=0.0)" />
    <meta http-equiv="Page-Exit" content="revealtrans(duration=0.0)" />
    
    <!--[if lt IE 7]>
    	<link rel="stylesheet" type="text/css" href="css/ie6-and-down.css"" />
    <![endif]-->
    <!--[if IE 7]>
    	<link rel="stylesheet" type="text/css" href="css/ie7.css" />
    <![endif]-->
    <!--[if gt IE 7]>
    	<link rel="stylesheet" type="text/css" href="css/css_stylesheet.css" />
    <![endif]-->
    <!--[if !IE]><!-->
    	<link rel="stylesheet" type="text/css" href="css/css_stylesheet.css" />
    <!--<![endif]-->
    
    <script type="text/javascript">
    
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-833604-5']);
      _gaq.push(['_trackPageview']);
    
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();
    
    </script>
    
    </head>
    
    <body>
    	<div id="shadow_container">
    		<div id="shadow_top"></div>    
        	<div id="shadow_center"></div>
        	<div id="shadow_bottom"></div>
        </div>
        
        		<div id="main_container">
                	<div id="logo_products">
                    <a style="display:block;height:100%;width:100%;" href="index.html"  title="Back to startpage"></a>
    				
                    </div>
                    <div id="main_navigation">	
                    	<ul>
                    	<li><a href="index.html" class="products">HOME</a></li>
                        <li><a href="products.html" class="products">PRODUCTS</a></li>
                        <li><a href="about.html" class="products">ABOUT</a></li>
                        <li><a href="stores.html" class="products">STORES</a></li>
                        <li><a href="news.html" class="products">NEWS</a></li>
                        <li><a href="contact.html" class="products">CONTACT</a></li>
                        </ul>
                        </div>
    				
                    <div id="artwork_container_products">
            			
                        <div id="main_opacity">
                        	
                            <div id="sub_navigation">
                            	<ul>                                
                        		<li><a href="index.html" class="products_small">WHAT THE ...</a></li>
                       		    </ul>
                            </div>
                        
                        	<div id="subject">
                            <p class="products_subject">404 Error</p>
                            </div>
                        
                        	<div id="content_products">
    						<h1><a class="playsets" href="index.html">Link not found!</a></h1>
                            <a href="index.html"><img src="images/snail.jpg" class="imagecenter1" title="Snail"/></a>
                        	<br /><p>Oops. The link you just clicked has been moved.</p>
                            <p>Try this <a href="index.html" title="******* "><strong>link instead.</strong></a></p>
                            
                                          
    
                          </div>
                       	</div>
        			</div>
    			</div>
    
    	
    </body>
    </html>
    I've also noticed the links do not work either [online, locally everything works great].

  • #4
    New Coder
    Join Date
    Aug 2009
    Posts
    37
    Thanks
    11
    Thanked 1 Time in 1 Post
    I finally found a solution to me 404 problem (no styled 404 in incorrect links with subdirectores, like www.yoursite.com/wrong/wrong.html).

    Normally I don't like bumping old old posts, but this was a serious problem for me to justify the bump. Naturally, with solution.

    ErrorDocument 404 /notfound.html
    ErrorDocument 404 http://www.yoursite.com/notfound.html

    Text in purple is new added line in the .htaccess file. I read somewhere this is not the perfect solution, but it works for me in FF and IE. I think you can delete the first line, but it is not bothering me.
    Last edited by rogierius; 09-21-2010 at 07:38 PM. Reason: I tried making the whole line purple, but because of the url, that aint possible.


  •  

    Posting Permissions

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