SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Jun 2004
    Location
    germany
    Posts
    263
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to handle user typing invalid page names by coding

    Hello
    I have seen may sites, when typed with certain file names and if that file names are not there then they handle that themselves by keeping a page and providing guidence.

    For example
    www.sitepoint.com/forums/newthread.php is a valied page.
    but if somebody type www.sitepoint.com/forums/oldthread.php and if that page is not there how we can handle this in our application and redirect them to where there should be.

    Thanks and regards
    vimal
    Knowledge is all about Sharing

  2. #2
    doing my best to help c2uk's Avatar
    Join Date
    May 2005
    Location
    Cardiff
    Posts
    1,832
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could define your own error page in the .htaccess file, a non existing file would be error 404 and could look like this in your .htaccess file:

    Code:
    ErrorDocument 404 http://www.yourdomain.com/errorpages/404.html
    For more information, have a look at the German page drweb: http://www.drweb.de/htaccess/index.shtml

    For all the others non German speaking out there, sorry I don't know any good website about this, maybe try Google with custom error page.

    P.S. Don't really know whether this works on Windows Servers as well.

  3. #3
    SitePoint Addict
    Join Date
    Jun 2004
    Location
    germany
    Posts
    263
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HELLO c2uk
    Vielen Dank
    i am not so gut in Deutsch and so could you explain to me in english or give me an english site in which they have given more details
    with regards
    vimal
    Knowledge is all about Sharing

  4. #4
    doing my best to help c2uk's Avatar
    Join Date
    May 2005
    Location
    Cardiff
    Posts
    1,832
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, thought Location: Germany indicates that you my know the German languages very well, guess I was wrong, for this reason I put in my Location England / Germany, living in England but I'm German and hence my English is not that great.

    To answer your question, you need to find out whether your host supports custom error pages / .htaccess

    Create your own errorpage, with all the links and styles you want, you only need to look at sitepoints own to get a feeling for what it should contain.

    Then create a file, called htaccess.txt, copy and paste the code above into it but make sure you change the filename to whatever your errorpage is called. The 404 is the typical error in case someone types in a webpage which doesn't exist on the server. For all the errors have a look at http://www.drweb.de/ressourcen/error_codes.shtml (it's still the German website but the errors are in English).

    Upload the htaccess.txt to the root directory of your webspace and change it to .htaccess - that should do the trick.

    Hope thats correctly explained in English, I'm not that good in explaining something in English which I learned in German. I haven't found a good web resource on this topic, yet but if you still have problems, I could look further into it.


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
  •