Changing site from html to php

17 replies
I need to add php code to my site. What is the best way to do this without having a negative effect on my rankings. Do I have to change all the file extensions and 301 redirect the old html pages to the new php ones? I kinda want to go at this one page because I'm scared of screwing everything up.
#changing #html #php #site
  • Profile picture of the author shabbirbhimani
    Best would be to make your .html files parse as PHP files. This way you get the power of PHP without the need to change any URLs
    {{ DiscussionBoard.errors[3525721].message }}
  • Profile picture of the author jminkler
    Originally Posted by brandon2664 View Post

    I need to add php code to my site. What is the best way to do this without having a negative effect on my rankings. Do I have to change all the file extensions and 301 redirect the old html pages to the new php ones? I kinda want to go at this one page because I'm scared of screwing everything up.

    Create an .htaccess rule

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

    or similiar
    {{ DiscussionBoard.errors[3525729].message }}
    • Profile picture of the author brandon2664
      Originally Posted by jminkler View Post

      Create an .htaccess rule

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

      or similiar
      2 Questions
      Do I have to start all my documents with a piece of php code?
      I read somewhere I should only parse the pages where I will actually use php code. Is there a way to just parse a certain directory or each individual page?

      Thanks for the help.
      {{ DiscussionBoard.errors[3532166].message }}
      • Profile picture of the author Christian Little
        Originally Posted by brandon2664 View Post

        Can I do that in cpanel or do I have to go into my htacccess file? Will I have to rename my pages to php? Do I have to start all my documents with a piece of php code?

        Thanks for the help.
        In cPanel, scroll down to the bottom an click on "Apache Handlers". That's where you can configure it.

        You might need to talk to your host about the specific entry to put though, as it depends on the version of PHP and a few other factors.

        But it will be something like:

        Handler: application/x-httpd-php
        Extensions: .php .html

        Though your host might have it enabled already as a global setting, so you should just test it first before modifying your personal Apache handlers.
        {{ DiscussionBoard.errors[3532176].message }}
      • Profile picture of the author kjhosein
        Originally Posted by brandon2664 View Post

        2 Questions
        Do I have to start all my documents with a piece of php code?
        I read somewhere I should only parse the pages where I will actually use php code.
        Actually, nope! As long as your site is set up to parse .php files as such, then you could have a file.php that only contained HTML and that would be perfectly fine.

        Originally Posted by brandon2664 View Post

        Is there a way to just parse a certain directory or each individual page?
        Yup, you could but there's no real benefit (that I can think of) to doing so.

        BTW, while the AddType approach would work, another approach would be to create a PHP version of your HTML files and 301 redirect the HTML URLs to the PHP ones.
        Ex: index.html ---301 redirect---> index.php

        HTH!
        Signature
        <!--PM me for a quicker reply. Thx!-->
        {{ DiscussionBoard.errors[3533274].message }}
  • Profile picture of the author stevemack
    First, prepare your .html files for conversion and then redirect HTML file requests to PHP files using your .htaccess file. If you don't have, create a file and the following code to that file and save it.

    RedirectMatch permanent ^(.*)\.htm(l?)$ $1.php

    the above query will take request for .html files and redirect it to .php.
    {{ DiscussionBoard.errors[3533358].message }}
  • Profile picture of the author joy1986joy
    You can just copy the .html file to .php file. thats all.
    Signature
    {{ DiscussionBoard.errors[3539924].message }}
    • Profile picture of the author kjhosein
      Originally Posted by joy1986joy View Post

      You can just copy the .html file to .php file. thats all.
      That's only a half-truth that only sometimes turns out to be true; it's not a given. It all depends on whether or not your hosting environment has the PHP engine installed and integrated with your web server. The web server also needs to be configured to parse (or handle) files with the .php extension as PHP. i.e. it sends the PHP bits to the PHP engine to interpret and the PHP engine sends back the HTML output to the web server.
      Signature
      <!--PM me for a quicker reply. Thx!-->
      {{ DiscussionBoard.errors[3542851].message }}
      • Profile picture of the author brandon2664
        I went to hostgator and found this:
        "To get regular html pages to handle php code, you need to add this line to your htaccess file.
        AddHandler application/x-httpd-php5 .html .htm
        It is highly recommended that you never allow html pages to automatically handle php or shtml, because this forces all of your html pages to be processed by the server first. Instead, please rename your files to .php or .shtml whenever possible."

        Is it really that bad if all my html pages are processed by the server first?
        {{ DiscussionBoard.errors[3544059].message }}
        • Profile picture of the author kjhosein
          Originally Posted by brandon2664 View Post

          Is it really that bad if all my html pages are processed by the server first?
          Hi @brandon - think about it from their point of view - they would rather a plain HTML not have to also go through the PHP processor if it didn't absolutely have to. This saves them computer resources, and also helps out the rest of the sites on the server.

          From your perspective, if you have an all HTML file, the web server will serve it up faster if it does not go through the PHP engine.

          So to answer your question, it's really bad if it ends up sucking up more resources to the point of dragging down your site and/or the server.

          HTH!
          Signature
          <!--PM me for a quicker reply. Thx!-->
          {{ DiscussionBoard.errors[3544543].message }}
  • Profile picture of the author voitenkos
    you have to make sure you have a web server like apache installed as well
    {{ DiscussionBoard.errors[3556161].message }}
    • Profile picture of the author oknoorap
      just rename your .html to .php and add htaccess rules.
      Signature

      Just Web Developer.

      {{ DiscussionBoard.errors[3556461].message }}
  • Profile picture of the author CliveG
    If you've already done some SEO work on the old site and you change to .php files make sure that you add some redirects to your webserver configuration file (or htaccess).
    {{ DiscussionBoard.errors[3576092].message }}
    • Profile picture of the author Mattasdan
      I wonder if this is going to affect my site ranking. Now two of my keywords are coming in the first page in the googe. I'm afraid that this change may affect my keyword positions. Need some advice...
      {{ DiscussionBoard.errors[3578753].message }}
      • Profile picture of the author CliveG
        Originally Posted by Mattasdan View Post

        I wonder if this is going to affect my site ranking. Now two of my keywords are coming in the first page in the googe. I'm afraid that this change may affect my keyword positions. Need some advice...
        If you have got something that works don't change it for the sake of it.
        {{ DiscussionBoard.errors[3579219].message }}
        • Profile picture of the author Mattasdan
          @CliveG...Thanks for your piece of advice!

          I was really confused....
          {{ DiscussionBoard.errors[3585587].message }}
  • Profile picture of the author indianbill007
    I can help you out. Hit me up.
    {{ DiscussionBoard.errors[3591867].message }}

Trending Topics