+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Make this type of 404 page

  1. #1
    biscoolcool's Avatar
    biscoolcool is offline x10Hosting Member biscoolcool is an unknown quantity at this point
    Join Date
    Apr 2009
    Posts
    53

    Make this type of 404 page

    I know how to make a 404 page, and how to make it work. Heres my question: If I go on mywebsite.com/fakeurl it redirects me to mywebsite.com/404 page.
    If you go to MS http://www.microsoft.com/fakeurl it doesn't redirect you. It puts fakeurl (your invalid request) in the search box.
    How do I do this for my website? Do I need mod_rewrite?
    If you found me useful why not add some reputation or donating some credits?(for the Recipient name write biscoolcool):drool:

    Click here to visit my website. What do you think?

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Make this type of 404 page

    It probably does not 'redirect' you. Look at the URL in the address window next time your site throws a 404.

    1. Create a file, call it 404.php (can name it anything, just easier to keep track of if you name it for the error). Should be a php file.
    2. Make the page pretty, etc. You can access the URI (relative to document root ) by using

    Code:
    <?php echo $_SERVER[ 'REQUEST_URI' ] ?>
    Example of full page...
    HTML Code:
    <!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" xml:lang="en" lang="en">
    
    <head>
      <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
      <title>Not here, I looked for it.</title>
    	<style type="text/css">
    		body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
    		div.dialog {
    			width: 25em;
    			padding: 4em 4em;
    			margin: 4em auto 0 auto;
    			border: 2px solid #bbb;
    			border-right-color: #777;
    			border-bottom-color: #888;
    		}
    		h1 { font-size: 110%; color: #f00; line-height: 1.5em; }
    		h2 { font-size: 90%; color: #000; line-height: 1.5em; }
    		h3 { font-size: 80%; color: #333; line-height: 1.5em; }
    		h4 { font-size: 70%; color: #666; line-height: 1.1em; }
    	</style>
    </head>
    <body>
    <div class='dialog'>
    <h1>__________  404  __________</h1> 
    
    <p>
    
    <h2>Sorry, you must have dialed a wrong number</h3> 
    <h3>The page you requested , <?php echo $_SERVER[ 'REQUEST_URI' ] ?> , cannot be found at this moment.</h3>
    <h4>I looked for it. Honest. It's not there</h4>
    </p>
     </div>
    
    </body>
    </html>
    3. Add to .htaccess (I keep my custom error pages in a error/ subdirectory.)

    Code:
    ErrorDocument 404 /error/404.php
    Last edited by descalzo; 10-26-2009 at 07:34 PM.
    Nothing is always absolutely so.

  3. #3
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Make this type of 404 page

    When the ErrorDocument directive is given a local URL path, it shouldn't redirect (see the ErrorDocument documentation for details). What are the configuration lines from your .htaccess that mention the error documents by URLs? For example, list all ErrorDocument and any applicable RewriteRule lines.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  4. #4
    biscoolcool's Avatar
    biscoolcool is offline x10Hosting Member biscoolcool is an unknown quantity at this point
    Join Date
    Apr 2009
    Posts
    53

    Re: Make this type of 404 page

    No I still get redirected. If I type in a random URL like http://bit.ly/TGP7t(please don't write the real url I don't want this page to get indexed) I still get redirected.
    Last edited by biscoolcool; 10-26-2009 at 08:01 PM.
    If you found me useful why not add some reputation or donating some credits?(for the Recipient name write biscoolcool):drool:

    Click here to visit my website. What do you think?

  5. #5
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Make this type of 404 page

    Are you using a CMS?

    Could you post your .htaccess file?

    (Just noticed that it redirects you from your .co.cc domain to your exofire.net )
    Last edited by descalzo; 10-26-2009 at 08:47 PM.
    Nothing is always absolutely so.

  6. #6
    like2program is offline x10 Sophmore like2program is an unknown quantity at this point
    Join Date
    Nov 2007
    Location
    In a hole at the bottom of the sea
    Posts
    244

    Re: Make this type of 404 page

    I must point out that this is very liable to be used for XSS the way you coded it, I would recommend that the input is sanitized before you directly output it to the page.

    example "http://web.site.com/<script>XSS()</script>"
    Last edited by like2program; 10-26-2009 at 08:47 PM.

    - Useful Links -
    || Free hosting Support || Request Unsuspension || Sign up for Free Hosting || Rules and Regulations ||
    || The x10 Commandments || Terms of Service || How do the credits work? ||


    If you found this useful or interesting hit the blue tick or donate some credits!

    My site is worth



  7. #7
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Make this type of 404 page

    Quote Originally Posted by like2program View Post
    I must point out that this is very liable to be used for XSS the way you coded it, I would recommend that the input is sanitized before you directly output it to the page.

    example "http://web.site.com/<script>XSS()</script>"
    Point taken.

    Just as quick code examples for form input etc, I often do not include all the sanity checks. I hope the people reading the examples understand the problems with XSS, SQL injection, etc.

    I do not use the above code for my error pages. I wanted to use $_SERVER[ 'REQUEST_URI' ] to show how you can access the original request in an error document.
    Nothing is always absolutely so.

  8. #8
    pythondev is offline x10Hosting Member pythondev is an unknown quantity at this point
    Join Date
    Mar 2009
    Posts
    59

    Re: Make this type of 404 page

    for 404 put in a .htaccess folder in your httpdocs folder
    an example below

    Code:
    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
    
    ErrorDocument 404 /index.php?p=404
    ErrorDocument 403 /index.php?p=403
    doing this way you can build your page exactly how you want it.
    other examples are:
    ErrorDocument 404 /errors/404.php
    ErrorDocument 404 /404.php
    ErrorDocument 404 /errors.php?error=404
    etc etc

  9. #9
    biscoolcool's Avatar
    biscoolcool is offline x10Hosting Member biscoolcool is an unknown quantity at this point
    Join Date
    Apr 2009
    Posts
    53

    Re: Make this type of 404 page

    Quote Originally Posted by like2program View Post
    I must point out that this is very liable to be used for XSS the way you coded it, I would recommend that the input is sanitized before you directly output it to the page.

    example "http://web.site.com/<script>XSS()</script>"
    Don't Understand a thing.
    I don't use any CMS.
    If we are starting with the .htaccess I have another question.
    I kept on trying to find a code so that when a visitor types my website with www it transfers them to the non www page. I found them but none work.
    I have 2 .htaccess files.
    File 1) In the root
    Code:
    ErrorDocument 404 http://bit.ly/3ZpDr5/errordocs/404.php
    NOTE: I don't want to write mu URL in text. The .htaccess files has the real name instead of the bit.ly one.
    File 2) In public_html
    Code:
    #prevent viewing of .htaccess
    <Files .htaccess>order allow,denydeny from all</Files>
    # Redirect if NOT example.com (exactly) to example.com 
    
    #switch php extentionAddType application/x-httpd-phpv2 .htm .html
    #errorsErrorDocument 404 http://bit.ly/3ZpDr5/errordocs/404.php
    If you found me useful why not add some reputation or donating some credits?(for the Recipient name write biscoolcool):drool:

    Click here to visit my website. What do you think?

  10. #10
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Make this type of 404 page

    As mentioned in a previous post and the linked documentation for ErrorDocument (there's a reason I wrote my sig; note the bits about reading links and answering questions), use a local URL path to keep from redirecting. By prefixing the error document URL with "http://bit.ly", you're causing a redirect.

    Quote Originally Posted by biscoolcool View Post
    If we are starting with the .htaccess I have another question.
    I kept on trying to find a code so that when a visitor types my website with www it transfers them to the non www page. I found them but none work.
    See the Apache URL Rewriting Guide, Canonical Hostnames section.
    Last edited by misson; 10-27-2009 at 04:05 AM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. what type of page do u prefer
    By delon in forum Graphics & Webdesign
    Replies: 4
    Last Post: 01-24-2009, 06:51 PM
  2. [REQ][$$$]1 page image flash redesign for choclate sales
    By tgkprog in forum The Marketplace
    Replies: 5
    Last Post: 11-17-2008, 09:53 AM
  3. Replies: 7
    Last Post: 05-07-2008, 05:27 AM
  4. Cannot edit in Front Page
    By katyW in forum Free Hosting
    Replies: 9
    Last Post: 05-26-2005, 06:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers