How to make an html page PHP?

by 30 replies
37
Hey everyone, I am using the conversion chicken to do my split testing, but it requires you to have the pages you want to split test as a PHP extension not htm or html.

Is there a way to take a page with the html extension and change it to PHP or do I need to start from scratch?

Thanks, I am very new to internet marketing and about the worst there is when it comes to techie stuff, so dont expect me to know anything!

Ashley
#programming #html #make #page #php
  • You can't exactly make an HTML page a php page, but you can use php code to call an HTML page to the broswer for display.
    • [1] reply
    • Cool, how do I do that? Is it hard?

      Thanks for the reply
      Ashley
      • [1] reply
  • just rename the page with the extension of php, change index.html to index.php, it will still work the same.

    The only difference will be the web server will pass the page to the PHP preprocessor before sending to the browser, being that there is no php code in the file, it will only add a few microseconds to the processing of the page.
    • [1] reply
    • This is the most simple answer. Just rename index.html to index.php and you're good to go. In the future you can add php if you like also.
  • Website creator yola.com creates its pages in php. It's pretty easy to use too. Might be an option for you.
    • [1] reply
    • Their or programs on the open market now that let you create a PHP version of your html site and keep both of them, great for split testing. Off the top of my head I can't think of the one I was just looking at, but give Big G a query with php converter and see what you get!

      Hope this helps!
  • Banned
    [DELETED]
    • [1] reply
    • Hi,

      If you just need to call a PHP file and you have a HTML file, simple rename the file, for example. index.html would become index.php. Your web server will treat the PHP file differently but as you won't have any actual PHP code in there, it will not produce any difference.

      To put PHP code into the file, you would have to "surround" the php code with <?PHP your PHP code would go here ?>

      Hope that helps.
      Lee.
      • [1] reply
  • Ashley, Lee is correct - all you need to do is simply rename your file with a "php" extension. So "index.html" can simply be renamed "index.php".

    It's as simple as that!

    Bill
    • [1] reply

    • YEP! I got an email back from Tim and he said that you all were correct. All I have to do is rename them with PHP on the end.

      Thanks for the help
      Ashley
  • Also you can use .htaccess to run html and htm files with php code inside them, I do this with all my websites, makes it easier to load the same headers, navigation menus and footer, and then I just call them into my html file.

    For web servers using PHP as apache module add the following to your .htaccess :
    AddType application/x-httpd-php .html .htm

    Then they will run with the html extension and execute the php code
    • [1] reply
    • This doesn't work on many servers since an update to php and apache a few months ago.
      I had to change several hundred pages over to php file names to use my includes. Took forever and then had to do redirects to all the new files.

      If you think there is the slightest posiblity that you will ever want to use php on your site, name your files with a php extension to begin with.
      • [2] replies
  • Rename it, as simple as that.

    If you have tons of files and if you use unix/linux, put the commans like the following in each line of the shell script:

    and wola, all were automatically done...
  • Banned
    yes it is as simple as renaming files from *.html to *.php,as far as writing programming code is concerned it is mainly required if you need to generate the content dynamically or your website needs to talk to database , extract values and display on your website.
  • it's easy just use the ftp program to rename the file..
    hopes that help
  • you need to know more HTML + CSS + JavaScript before you can use PHP
  • Save Your money. Get Netbeans which is free and use their help system both as regular lessons and Video How To's
  • There is actually software that can do that. It can convert any html to php documents instantly. You can find it at htmltophp.com.

    I hope it helps.
  • This forum is outstanding, but this thread is a hilarious example of people over complicating things or not correctly reading the original question.

    As a few people mentioned, the simple and most correct answer is to rename the .html/.htm file with a .php extension.

    Additionally, this post within the thread is helpful:

    Happy 4th all.
  • Actually takingaction, what you say is the most correct answer is only if the site is new and no pages in index or other sites linking to it.

    In general, the most correct answer is placing

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

    in the httpd.conf or vhost.conf file. This will cause pages with htm or html extensions to be processed as php. This results in no change in the URLs of the site. In this way any indexing will be maintained and any links to the site's pages will be valid.
    • [1] reply
    • Hmmm... makes sense rtrotter.

      Please note that I quoted someone as mentioning that you should not rename the pages if they are indexed and ranked.

      I unfortunately made the assumption that the person asking the question did not have page rank or many backlinks to the site in question. That's totally my bad.

      The best way to do it in that case is to ask your client if the pages are indexed and, if so, whether they are ranked. If so, then it's best not to mess with renaming (again, I added a quote about this in my post). This also goes with backlinks. If there are a decent amount of good backlinks to secondary pages (not the index page) and the client wants these to work with php, then yes, don't change the extensions of those pages.

      The main problem with your solution is that it only works some of the time. I've worked with hosting companies where this does not work. Sure, they may not be great hosting companies, but my clients choose them, not me. Therefore I have to do what works, and the php renaming works every time.

      More than meets the eye I suppose... thanks for the comment rtrotter.
  • Its fine to change the file extension, just remember to 301 redirect the old pages, to the new pages. Can be done in htaccess as well, so rtrotters suggestion might be the best anyway.
  • To parse the php code in .html extenction , just add the following line of code in .htaccess file .

    AddType application/x-httpd-php .html .htm
  • Just to expand it a little, using

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

    does work nicely (if hosting company allows it) and it is not limited. On one of my sites I do

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

    and then have fun making the page interesting and highly dynamic. Just have to be sure and send the correct headers to specify content type.

    Rodney
    • [1] reply
    • just rename the page with the extension of php, change index.html to index.php, it will still work the same.

      The only difference will be the web server will pass the page to the PHP preprocessor before sending to the browser, being that there is no php code in the file, it will only add a few microseconds to the processing of the page.

Next Topics on Trending Feed

  • 37

    Hey everyone, I am using the conversion chicken to do my split testing, but it requires you to have the pages you want to split test as a PHP extension not htm or html. Is there a way to take a page with the html extension and change it to PHP or do I need to start from scratch?