301 redirects, from .html to .php

Discussion in 'HTML & Website Design' started by uttoransen, May 29, 2007.

  1. #1
    i have a site made in frontpage, the pages are all .htm, i want to redirect on the dynamic page, which are .php!!
    how to make a 301 redirects in the old .htm pages, thanks:)
     
    uttoransen, May 29, 2007 IP
  2. Fold

    Fold Peon

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do you have an apache server with mod_rewrite installed? If so you can use a .htaccess file to set up redirects.
     
    Fold, May 29, 2007 IP
  3. uttoransen

    uttoransen Prominent Member

    Messages:
    8,227
    Likes Received:
    550
    Best Answers:
    0
    Trophy Points:
    320
    #3
    is there any codes that i can simply add to my .htm files that will redirect the pages to the php counter parts! thanks:)
     
    uttoransen, May 29, 2007 IP
  4. nabil_kadimi

    nabil_kadimi Well-Known Member

    Messages:
    1,065
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    195
    #4
    As he said using mod_rewrite is the best thing to do.

    Or i you want to add code to your .htm files, you must configure the "php.ini" to tell the php to parse .htm files

    And then add this to your .htm file

    
    <?php
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://www.exemple.com/script.php");
    exit();
    ?>
    
    PHP:
     
    nabil_kadimi, May 31, 2007 IP
  5. idotcom

    idotcom Well-Known Member

    Messages:
    522
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    108
    #5
    If you have htaccess, you can do something like:

    
    
    AddType application/x-httpd-php .html .htm
    
    
    Code (markup):
    It will allow you to run PHP in .html files.

    I would make a new folder on the server like test/

    put the htaccess file with that code above in the folder

    make a index.html file with: <? echo "PHP Code in HTML file works"; ?>

    put that in the test/index.html

    Visit that page and if it works ok... you can do that.

    However, I know crappy frontpage puts a lot of garbage in their code, so you may have problems. Maybe use a copy of one of your frontpage pages and put the php code in there and try it. Good luck
     
    idotcom, May 31, 2007 IP