Find htm or html files on (Linux) server

Discussion in 'HTML' started by ©®, Aug 30, 2008.

  1. ©®

    ©® Guest

    I use a Linux/PHP hosting plan (not sure of the correct terninology - it
    is not Windows/ASP based) for a website.

    Is there a simple way that if someone types
    http://www.mydomain.com/info.html that it would find the webpage
    http://www.mydomain.com/info.htm (no "L" on the end) or vice versa: if
    someone types http://www.mydomain.com/info.htm that it would find the
    webpage http://www.mydomain.com/info.html (with "L" on the end)?

    I am not even sure what this "procedure" would be called so hope someone
    can help a newbie.
    Thanks
     
    ©®, Aug 30, 2008
    #1
    1. Advertising

  2. ©®

    Mike Duffy Guest

    "©®" <> wrote in news:g9autv$sdp$:

    > I use a Linux/PHP hosting plan (not sure of the correct terninology - it
    > is not Windows/ASP based) for a website.
    >
    > Is there a simple way that if someone types
    > http://www.mydomain.com/info.html that it would find the webpage
    > http://www.mydomain.com/info.htm (no "L" on the end) or vice versa: if
    > someone types http://www.mydomain.com/info.htm that it would find the
    > webpage http://www.mydomain.com/info.html (with "L" on the end)?
    >
    > I am not even sure what this "procedure" would be called so hope someone
    > can help a newbie.
    > Thanks
    >
    >
    >


    Despite that fact that I am one of the least knowledgable HTML "experts"
    here, I can tell you that:

    1) This is definitely NOT an HTML question. It is instead a question
    relating to the exact server you are using. It is likely Apache, because
    that is the most popular Unix-based server available. Find out if this is
    the case, and take your question to an Apache newsgroup / forum. Note also
    that you should be able to configure it to find a default extension. Using
    your example, "http://www.mydomain.com/info" should get the user to
    "http://www.mydomain.com/info.html" or "http://www.mydomain.com/info.htm",
    whichever actually exists.

    2) You could always use symbolic links within the Linux filesystem itself.
    There are a number of approaches to use. I suppgest asking in a Linux
    newsgroup / forum. Exactly how you do it depends on how often you intend to
    modify your content and how you intend to back up your website.
     
    Mike Duffy, Aug 30, 2008
    #2
    1. Advertising

  3. ©® wrote:
    > I use a Linux/PHP hosting plan (not sure of the correct terninology - it
    > is not Windows/ASP based) for a website.
    >
    > Is there a simple way that if someone types
    > http://www.mydomain.com/info.html that it would find the webpage
    > http://www.mydomain.com/info.htm (no "L" on the end) or vice versa: if
    > someone types http://www.mydomain.com/info.htm that it would find the
    > webpage http://www.mydomain.com/info.html (with "L" on the end)?
    >
    > I am not even sure what this "procedure" would be called so hope someone
    > can help a newbie.
    > Thanks
    >
    >


    Agree this is not an HTML question, but with Apache there is a special
    file .htaccess file that will fix this for you. (That is 'htaccess' with
    a leading dot)

    Firstly, name all you documents with full 4-letter 'html' extension. A
    tip is to always use all lowercase and you will not have trouble with
    case-insensitive Windows and and case-sensitive *nix & URLs

    Secondly, create a plain textfile and name it ".htaccess" You will not
    be able to do this on your Windows desktop because Windows will throw an
    error that a file must have a filename and .htaccess looks to Windows as
    just a file extension.

    Work-a-rounds for this are:

    1) Some hosting companies provide a .htaccess file editor in their
    control panel.

    2) Create the file directly on the server

    3) Create a plain textfile in Windows, upload it an rename on server to
    ..htaccess

    1 & 3 are the usual methods.

    Thirdly, the .htaccess file should have this content:

    # Start of .htaccess file
    # Turn on the URL rewriting module
    RewriteEngine on

    # The rule to redirect all 'htm' requests to 'html'
    RewriteRule ^(.*)\.htm$ $1.html [NC]
    # End of .htaccess file

    That is it. Any request, "foo.htm" or "foo.html" will bring you to
    "foo.html"

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Aug 30, 2008
    #3
  4. ©®

    Nico Schuyt Guest

    ©® wrote:
    > I use a Linux/PHP hosting plan (not sure of the correct terninology -
    > it is not Windows/ASP based) for a website.
    >
    > Is there a simple way that if someone types
    > http://www.mydomain.com/info.html that it would find the webpage
    > http://www.mydomain.com/info.htm (no "L" on the end) or vice versa: if
    > someone types http://www.mydomain.com/info.htm that it would find the
    > webpage http://www.mydomain.com/info.html (with "L" on the end)?


    You need a .htaccess-file.
    Basics: http://corz.org/serv/tricks/htaccess.php
    Specific: http://corz.org/serv/tricks/htaccess2.php

    --
    Nico
     
    Nico Schuyt, Aug 30, 2008
    #4
  5. ©®

    ©® Guest

    Thanks very much for all the replies and suggestions.
     
    ©®, Sep 3, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Linden

    Deny access to htm files

    Brian Linden, Jan 13, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    2,864
    MichaelAaronson
    Jan 27, 2005
  2. Ralf Koms

    [JSP]: Including HTM files

    Ralf Koms, Oct 11, 2004, in forum: Java
    Replies:
    1
    Views:
    361
    Ralf Koms
    Oct 11, 2004
  3. =?Utf-8?B?TWlrZQ==?=
    Replies:
    3
    Views:
    312
    David
    Apr 9, 2007
  4. Replies:
    3
    Views:
    1,465
    Rolf Magnus
    Jan 18, 2009
  5. Replies:
    6
    Views:
    167
    Dr.Ruud
    Feb 6, 2007
Loading...

Share This Page