The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How can I make pages load regardless if .htm or .html is called?

Discussion in 'General Discussion' started by BianchiDude, Dec 1, 2005.

  1. BianchiDude

    BianchiDude Well-Known Member
    PartnerNOC

    Joined:
    Jul 2, 2005
    Messages:
    619
    Likes Received:
    0
    Trophy Points:
    16
    How can I make pages load regardless if .htm or .html is called?

    I have page new.htm, I want that to come up whether someone types in new.htm or new.html

    Can that be set in cpanel?
     
  2. sawbuck

    sawbuck Well-Known Member

    Joined:
    Jan 18, 2004
    Messages:
    1,367
    Likes Received:
    5
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Assume you have tested and it's not working?

    It should work by default as .htm/.html fuctionality is normally included in the DirectoryIndex statement in httpd.conf.
     
  3. Marty

    Marty Well-Known Member

    Joined:
    Oct 10, 2001
    Messages:
    630
    Likes Received:
    1
    Trophy Points:
    18
    That is not what the op means. He means if somebody calls for www.domain.com/new.html but new.html does not exist and new.htm does exist, is there a way to get he webserver to display the contents of new.htm automatically when there is a 404 error on new.html.
     
  4. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    The best long term option would be to design all URLs to not be specific to the format of the document.

    For example, instead of having http://www.example.com/new.html, have http://www.example.com/new/index.html, which to the user would only need to be http://www.example.com/new/, therefore helping to both reduce the chance of the user mis-typing a URL and increase the chance of the user remembering the URL.

    Furthermore, URLs of the form http://www.example.com/new/index.html could then be changed, if needed, to http://www.example.com/new/index.php without needing to change any links - more forwards compatible.

    However such a suggestion is not a solution to the specific problem at hand, nevertheless it helps minimise the risk of such problems occurring and so I thought it worth mentioning.
     
  5. dalem

    dalem Well-Known Member
    PartnerNOC

    Joined:
    Oct 24, 2003
    Messages:
    2,577
    Likes Received:
    40
    Trophy Points:
    48
    Location:
    SLC
    cPanel Access Level:
    DataCenter Provider
    a simple .htaccess file will do the trick

    Options +FollowSymlinks
    rewriteengine on
    rewriterule ^(.*)\.htm$ http://yourdomain.com/$1.html [r=301,nc]

    the above asumes that you have all html files and want all htm to go to there corisponding html files reverse the code if you want it to go the other way


    warning with the above example if you have working htm files it will redirect them to html if they do not exist 404 :D
     
Loading...

Share This Page