Display PageNotFound Page

Discussion in 'Apache' started by mummana, Feb 5, 2009.

  1. #1
    Hi,

    We are using apache as web server, Jboss as application. Mod_jk is the connector for them.

    If the webContext name is wrong, how to redirect to 404 page from apache server. Assume that correct page is: http://mysite.com/myapp/login.jsp

    If any body requested with wrong context name, we need to show page not found page. Example: http://mysite.com/myappA/login.jsp.

    Please help me regarding.

    Thanks
    Srini
     
    mummana, Feb 5, 2009 IP
  2. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #2
    Add the following to your .htaccess file replacing the samples with the actual file names.

    That will redirect all 404 errors to the page filename.php
     
    Colbyt, Feb 5, 2009 IP
  3. mummana

    mummana Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi,

    Where we need to place .htaccess file?
     
    mummana, Feb 5, 2009 IP
  4. mummana

    mummana Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi,

    I have ErrorDocument 404 /404.html in the .htaccess page and I have place .htaccess in document root folder.
    and I have added in httpd.conf, but it is not displaying the 404 page when we give wrong web context name.

    Could you please help me regarding.

    Thanks
    Srini
     
    mummana, Feb 5, 2009 IP
  5. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #5
    You aren't on a cPanel server? The .htacess file should be in the main public folder. public_html on cPanel, httpdocs, www on others panels. Place it where the the index page for mysite.com is located.
     
    Colbyt, Feb 6, 2009 IP
  6. mummana

    mummana Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks Colbyt for the update. It is working fine when request a wrong file from the root directory.

    http://mysite.com/abc.html is showing the 404.html correctly. But when we request with wrong web context like http://mysite.com/myAppSSS/login.jsp, it shows 404 error page from application server, not the actual configured 404.html page?

    Could you please help me how to display the 404.html when we requrested with wrong page.

    Thanks
    Srini
     
    mummana, Feb 7, 2009 IP
  7. darrenbeige

    darrenbeige Peon

    Messages:
    97
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    You may need to use this directive (in your httpd.conf)

    RewriteBase /

    Also, try entering the 404 directives, into a .htaccess file (again using the RewriteBase directive)

    Thanks,
     
    darrenbeige, Feb 8, 2009 IP