Skip navigation
Currently Being Moderated

Setting up Permanent Redirects (and .html go to .php)

May 3, 2012 5:48 PM

Hi all,


There is a bigger story but I'll try to keep to just the main issue... I'm a newbie at this so please forgive terms etc.



GOAL: Setting up permanent redirects from (all html) to  (all with the same urls file name but all now = .php)


So I want to do 2 things:


1 - redirect everything from old site to new site

2 - redirect ALL OLD .htm and .html to NEW .php like:


EX: to


so in in .htaccess file I added:


1 -  at bottom...

redirect 301 /




2 - below or above previous both did not work...

RewriteEngine On

RewriteRule ^(.*)\.html$ $1.php [L]


THAT SEEMS TO NOT WORK - it goes to new site but stays on the .html page not the .php version of the same page


Q: How do I get this working?

  • Sudarshan Thiagarajan
    4,000 posts
    Oct 15, 2010
    Currently Being Moderated
    May 3, 2012 11:18 PM   in reply to revdave

    You should ideally redirect wildcard from the old domain to the new domain. You need not modify .htaccess. You could use your cPanel to do this for you. Login to cPanel > Redirects. Configure your new domain as a wildcard redirect with 301 Permanent here.


    Renaming files from .html to .php happens on your new domain. Open the root .htaccess on your new domain and paste the following code all the way at the top:


    Options +Indexes

    Options +FollowSymlinks

    RewriteEngine on

    RewriteBase /

    RewriteRule ^([^.]+)\.php$ $1.html [L]

    Try it out and let us know how it works.


    A quick tip: People usually rewrite .php to .html for SEO (even though it doesn't really matter)! But, this is the 1st time I'm seeing a request for rewriting .html to .php! Is there a specific reason why you're moving to .php? Do you have a lot of .php code on your new site?

    Mark as:
  • Currently Being Moderated
    May 4, 2012 12:55 AM   in reply to revdave

    You can do this in the htaccess file like below listing all the sites pages BUT it's a bit long winded if you have 30 plus page. There is  much shorter method than listing all the pages which I can't remember but maybe someone else can.



    redirect 301 /pages/about_us.html


    redirect 301 /pages/latest_news.html

    Mark as:
  • Currently Being Moderated
    May 14, 2012 11:37 PM   in reply to revdave

    revdave wrote:


    So I'm just double checking that this method listing each page individually on  .htaccess file should be the best way to move from .htm or .html TO .php &  *PRESERVE GOOGLE RANKINGS* - CORRECT?



    redirect 301 /mypage1.html

    redirect 301 /mypage2.htm




    I'm not sure its the most efficient way but its the way I have done it in the past to preserve Google rankings.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points