.htaccess - htm / html question

Discussion in 'HTML' started by nllamas, Apr 1, 2006.

  1. nllamas

    nllamas Guest

    Hi folks,

    Checking my error logs, today, I find that some people are occasionally
    requesting pages with an .htm extension rather than .html
    Not sure why this is - all my pages have always ended in .html.

    Anyway, is there something I can put in my .htaccess file to direct requests
    for .htm pages to the correct .html file.
    I know I can use a redirect for each individual page (such as:
    RedirectPermanent /somepage.htm http://www.example.com/somepage.html )
    but I was hoping for something simpler, so I don't have to list every page
    individually.

    Thanks!
    nllamas
     
    nllamas, Apr 1, 2006
    #1
    1. Advertising

  2. nllamas

    Steven Guest

    On Sat, 01 Apr 2006 21:49:21 GMT, "nllamas" <> wrote:

    >Checking my error logs, today, I find that some people are occasionally
    >requesting pages with an .htm extension rather than .html
    >Not sure why this is - all my pages have always ended in .html.
    >
    >Anyway, is there something I can put in my .htaccess file to direct requests
    >for .htm pages to the correct .html file.


    I think RewriteCond and RewriteRule will do what you want but offhand I
    can't say exactly what to put in .htaccess as I haven't done it.

    Here is an example from one of my directories :

    # If no filename, use index.htm
    # If file missing, redirect (permanent) to Exetel

    RewriteEngine on
    RewriteRule ^$ index.htm [L]
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteRule ^(.*)$ http://home.exetel.com.au/phelum/$1 [R=301,L]

    I referred to the documentation at httpd.apache.org. Hopefully there
    will be an example there for what you want.

    --
    Steven
     
    Steven, Apr 1, 2006
    #2
    1. Advertising

  3. nllamas

    Jim Higson Guest

    nllamas wrote:

    > Hi folks,
    >
    > Checking my error logs, today, I find that some people are occasionally
    > requesting pages with an .htm extension rather than .html
    > Not sure why this is - all my pages have always ended in .html.
    >
    > Anyway, is there something I can put in my .htaccess file to direct
    > requests for .htm pages to the correct .html file.
    > I know I can use a redirect for each individual page (such as:
    > RedirectPermanent /somepage.htm http://www.example.com/somepage.html )
    > but I was hoping for something simpler, so I don't have to list every page
    > individually.


    Try http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
     
    Jim Higson, Apr 1, 2006
    #3
  4. nllamas

    nllamas Guest

    "Steven" <> wrote in message
    news:...
    > On Sat, 01 Apr 2006 21:49:21 GMT, "nllamas" <> wrote:
    >
    >>Checking my error logs, today, I find that some people are occasionally
    >>requesting pages with an .htm extension rather than .html
    >>Not sure why this is - all my pages have always ended in .html.
    >>
    >>Anyway, is there something I can put in my .htaccess file to direct
    >>requests
    >>for .htm pages to the correct .html file.

    >
    > I think RewriteCond and RewriteRule will do what you want but offhand I
    > can't say exactly what to put in .htaccess as I haven't done it.
    >
    > Here is an example from one of my directories :
    >
    > # If no filename, use index.htm
    > # If file missing, redirect (permanent) to Exetel
    >
    > RewriteEngine on
    > RewriteRule ^$ index.htm [L]
    > RewriteCond %{SCRIPT_FILENAME} !-f
    > RewriteRule ^(.*)$ http://home.exetel.com.au/phelum/$1 [R=301,L]
    >
    > I referred to the documentation at httpd.apache.org. Hopefully there
    > will be an example there for what you want.
    >
    > --
    > Steven


    Thanks Steven!
    I followed your suggestion and after a bit of hunting around I found:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^(.*)\.htm$ $1.html [R=permanent]

    and it does just the trick.

    Thanks again!
    nllamas
     
    nllamas, Apr 1, 2006
    #4
    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. Samuël van Laere

    Charset - htaccess question

    Samuël van Laere, Jul 9, 2003, in forum: HTML
    Replies:
    9
    Views:
    3,572
    T. Audry Glamour
    Jul 9, 2003
  2. Bart van den Burg

    .htaccess question

    Bart van den Burg, Sep 15, 2003, in forum: HTML
    Replies:
    3
    Views:
    487
    Bart van den Burg
    Sep 16, 2003
  3. mentalguy2004

    htaccess question...

    mentalguy2004, Aug 24, 2004, in forum: HTML
    Replies:
    3
    Views:
    429
    lostinspace
    Aug 24, 2004
  4. BusyGuy

    .htaccess question please

    BusyGuy, Sep 21, 2006, in forum: HTML
    Replies:
    6
    Views:
    525
    Jukka K. Korpela
    Sep 23, 2006
  5. Replies:
    6
    Views:
    182
    Dr.Ruud
    Feb 6, 2007
Loading...

Share This Page