Any method for redirecting .htm to .html

Discussion in 'Site & Server Administration' started by kslokesh, Nov 1, 2008.

  1. #1
    Is there any method to redirect .htm files to their respective .html files? and vice versa..

    is there any .htaccess or any other methods?

    Please help me..
     
    kslokesh, Nov 1, 2008 IP
  2. sourcer

    sourcer Well-Known Member

    Messages:
    960
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    120
    #2
    yep, you should use mod rewrite, search for some tutorials.
     
    sourcer, Nov 1, 2008 IP
  3. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #3
    Yes, using mod_rewrite as suggested above. However, you can't have it both ways, as that'd just be an infinite loop?
     
    jayshah, Nov 1, 2008 IP
  4. kslokesh

    kslokesh Well-Known Member

    Messages:
    153
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    #4
    Ya, I know that It wont work both ways simultaneously.. I just wanted to know whether it can be converted from one form to other OR is it a one way algorithm like...

    Where can I get the code for that or tutorials to do it?
     
    kslokesh, Nov 1, 2008 IP
  5. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #5
    Here's an untested sample:

    
    RewriteEngine On
    RewriteRule ^(.*?)\.htm$ $1.html [R=301,L]
    Code (markup):
    That should redirect .htm to .html, if not, play around a bit.

    Jay
     
    jayshah, Nov 1, 2008 IP