htm to php redirect

Discussion in 'Site & Server Administration' started by Jon12345, Dec 5, 2007.

  1. #1
    I have a website where my home page used to be mysite.com/index.htm. It has many links pointing to it.

    Now I have created mysite.com/index.php which is to be the new home page.

    What happens now? I will be getting some visitors to htm and some to php but the php page is my target page.

    What do I do?

    Thanks,

    Jon
     
    Jon12345, Dec 5, 2007 IP
  2. ismu

    ismu Peon

    Messages:
    247
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    copy & paste below as the content of your index.htm

    every time someone open index.htm, they will be redirected to index.php
     
    ismu, Dec 6, 2007 IP
  3. Jon12345

    Jon12345 Peon

    Messages:
    599
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Wouldn't I lose link juice that way? Isn't it better to do a 301 or 302 redirect?
     
    Jon12345, Dec 6, 2007 IP
  4. KenJay

    KenJay Peon

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Create .htaccess file and try this is.

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^mysite.com/index\.html$ [NC]
    RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]
     
    KenJay, Dec 7, 2007 IP
  5. Jean-Luc

    Jean-Luc Peon

    Messages:
    601
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I would use this .htaccess:
    RewriteEngine on
    RewriteRule ^(.*)\.html$ http://www.your_domain.com$1.php [L,R=301]
    
    Code (markup):
    This will redirect any hit on /something.html to /something.php.

    Jean-Luc
     
    Jean-Luc, Dec 7, 2007 IP
  6. Jon12345

    Jon12345 Peon

    Messages:
    599
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Jean-Luc, how would you do it so it will redirect only index.htm to index.php?
     
    Jon12345, Dec 7, 2007 IP
  7. Jean-Luc

    Jean-Luc Peon

    Messages:
    601
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Try this:
    RewriteEngine on
    RewriteRule ^(index)\.htm$ http://www.your_domain.com/$1.php [L,R=301]
    Code (markup):
    or better:
    RedirectPermanent /index.htm http://www.your_domain.com/index.php
    Code (markup):
    Jean-Luc
     
    Jean-Luc, Dec 7, 2007 IP