www.webdeveloper.com
Results 1 to 8 of 8

Thread: Convert html website to php

  1. #1
    Join Date
    Apr 2007
    Location
    Newcastle upon Tyne
    Posts
    61

    Question Convert html website to php

    I'm a complete novice when it comes to rewrites, I don't know enough about the code, and am frankly terrified of doing the wrong thing in converting my .html web pages to .php. (BTW, the reason for the conversion - to add header and footer includes plus dynamic features.)

    So far, I've found the .htaccess rewrite rule.
    PHP Code:
    RewriteEngine on
    RedirectMatch permanent 
    ^(.*)\.html$ $1.php 
    (I'd prefer not to include rewriting .htm pages as all of MY pages are .html)

    However, I'm very concerned about how search engines will treat this, and the implications for getting the site to be re-indexed.

    I've read that a better SEO technique may be to set up a 301 redirect (or is this exactly the same as what I've just proposed?)

    Something like:
    PHP Code:
    RewriteEngine on
    RedirectMatch 301 
    (.*)\.htmlhttp://www.example.com$1.php 
    I'm concerned that "playing" with htaccess may land me in deep waters, and any advice much appreciated.

  2. #2
    Join Date
    Jun 2008
    Location
    Europe
    Posts
    1,096
    I did it and did not have any problems... once you change your page extension from .html to .php it counts as a different page in Google so pagerank is lost.

  3. #3
    Join Date
    Apr 2007
    Location
    Newcastle upon Tyne
    Posts
    61

    Losing Pagerank…

    …how much of a disaster to the client is this? A matter of 2-4wks?

    Donatello - Much appreciate yr swift reply - I'm guessing I'm on the right track, anyway. I've heard some people use .htacess to get .html pages to act as .php

    This seems overly complex - but could it be a useful approach. Or do I just get on with conversion and let the client know of temp. loss of pagerank?

  4. #4
    Join Date
    Apr 2007
    Location
    Newcastle upon Tyne
    Posts
    61

    Make Apache parse .html as .php

    Make Apache parse .html as .php - is there a drawback to this?

    Is this what I would add to .htacess?

    AddType application/x-httpd-php .htm .html

  5. #5
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    AddType application/x-httpd-php .htm .html
    Is correct
    At least 98% of internet users' DNA is identical to that of chimpanzees

  6. #6
    Join Date
    Apr 2007
    Location
    Newcastle upon Tyne
    Posts
    61

    Convert html to php OR Make Apache parse .html as .php?

    Thanks, all
    And now… which would be the best method, in your opinions?

    I have two options:
    1/ Convert html to php
    My main concern is that this will scupper Pagerank (how big a deal is this? - how long to "repair" pagerank?)

    2/ Make Apache parse .html as .php
    How will my testing server treat this - i.e. so that I can work locally on pages?

    Also, possible issues getting this to work (I guess this isn't a reason for not doing it really): (http://www.besthostratings.com/artic...tml-files.html)

  7. #7
    Join Date
    Jan 2010
    Location
    Arizona
    Posts
    23
    When I changed over from HTML to PHP, all I did was change the extensions. Though my site is still in HTML, I wanted php for the include function. Static Header makes life easier lol.

    You shouldn't have an issue just changing the extensions and updating the links.

  8. #8
    Join Date
    Jun 2008
    Location
    Europe
    Posts
    1,096
    Here's what I use on GoDaddy hosting:
    This is my .htaccess file (in the ROOT folder of course).
    HTML Code:
    AddType application/x-httpd-php .php .htm .html
    AddHandler x-httpd-php .php .htm .html
    
    # switch GoDaddy's php extension handling for php5   
    AddHandler x-httpd-php5 .php   
    AddHandler x-httpd-php .php4  
    You will also notice that I had to add the handler for Godaddy to force php5. Even though I changed it in my hosting panel, for some reason it was continuing to run php4... so in frustration I fixed it with the .htaccess fix you see above.


    PS- If you switch to PHP5 on Godaddy, beware of this:
    http://www.webdeveloper.com/forum/sh...05#post1089205
    Last edited by donatello; 05-17-2010 at 01:48 PM.

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles