Can I put PHP in a HTML file?

by DavidMeade 10 replies
Hi folks,

I've a script that will only work in php and the site I want to use it on has html files. I don't want to change the html files because I want to use the script to track traffic. My traffic for this site comes from the search engines, so I think that if I change the file name it may eventually affect rankings.

Does anyone know if -
Is there a way to put php into a html file?

Or alternatively, is there a way to keep my pages in the search engines but have some sort of redirect to a php file?

Thanks,
Dave
#main internet marketing discussion forum #php #redirect
Avatar of Unregistered
  • Profile picture of the author imb
    You can make HTML run PHP lines, just put the following code in your .htaccess

    AddType application/x-httpd-php .html
    Signature

    {{ DiscussionBoard.errors[10761].message }}
  • Profile picture of the author Dennis Wagoner
    Hi Dave,

    Hope this helps..

    ONLamp.com -- Embedding PHP in HTML


    Dennis
    Signature

    {{ DiscussionBoard.errors[10762].message }}
    • Profile picture of the author DavidMeade
      Hi IMB, Dennis,

      I'll try those and post a quick note when I get them working.

      Thanks a mill,
      Dave
      {{ DiscussionBoard.errors[10766].message }}
    • Profile picture of the author Hugh Fraser
      Originally Posted by Dennis Wagoner View Post

      Hi Dave,

      Hope this helps..

      ONLamp.com -- Embedding PHP in HTML


      Dennis
      Hey,
      This is one of those things I just not think was possible, but then again we are dealing with technology that changes daily, which is very cool, Thanks Dennis, I'll book mark this page.

      Hugh
      {{ DiscussionBoard.errors[10789].message }}
      • Profile picture of the author zerofill
        The .htaccess change will work. Just remember that all html files will now be parsed as PHP whether there is PHP code in them or not.
        Signature
        Serp Shaker
        The IM World Will Be Shaken to the Core!
        Join my list at: IMCool.Biz
        New Podcast --> podcast.imcool.biz
        {{ DiscussionBoard.errors[10967].message }}
        • Profile picture of the author MoaddinFM
          don´t forget to backup all your files, especially the htacces file before any changes.

          It´s common sense, I know. But as soon as you forget 1 time ... *Caboooom Crahs Bang bup*

          Martin
          {{ DiscussionBoard.errors[10973].message }}
          • Profile picture of the author DavidMeade
            Hi,

            the code I put in my htaccess file is,

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

            My php scripts work fine now in html and I haven't had any problems with it.

            Dave
            {{ DiscussionBoard.errors[35285].message }}
            • Profile picture of the author BIG Mike
              Banned
              [DELETED]
              {{ DiscussionBoard.errors[35427].message }}
              • Profile picture of the author Zeus66
                Originally Posted by BIG Mike View Post

                And if your host is running PHP 5? Usually this will work:

                AddType application/x-httpd-php5 htm html
                AddHandler application/x-httpd-php5 .htm .html
                Man, I found this out the hard way! I use HostGator, and they run PHP 5. I could not for the life of me figure out why the PHP was acting screwy. Finally I found this answer... but it was after 3 days and lots of promises to quit forever and hack up my PC with an ax.

                John
                {{ DiscussionBoard.errors[95020].message }}
  • Profile picture of the author erday
    "Here's A Quick And Easy Software Tool That Will Allow You To Use PHP Code Inside Your Ordinary HTML Web Pages it's called PHP Activator"

    Download for Free! No you don't have to Opt-In just download.

    Enjoy.

    http://www.softwaregoldclub.com/gets...ivator_477.exe
    {{ DiscussionBoard.errors[91898].message }}
Avatar of Unregistered

Trending Topics