#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    4
    Rep Power
    0
    Hi Folks,

    Sorry if this is a bit remedial but I'd like to know if Apache (under Linux) can be made to pass PHP code over to PHP from within .html file rather that .php.

    I've tried putting php tags in my .html pages but they get sent straight through to the browser. Is this correct?


    Thanks.

    Andy
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    60
    Rep Power
    15
    You can set mime type in httpd.conf to read .html or .htm files as php files, and then all html files will have to be interpreted through php. Why can't you just name your files .php, .php3, .php4, or .phtml?

    This is how my httpd.conf reads where it refers to different versions of php. You would just add .htm or .html to the correct line. NOTE using this on Win32 does not allow you to use both php3 and php4 as it does on *nixes.

    AddType application/x-httpd-php3 .phtml
    AddType application/x-httpd-php3-source .phps
    AddType application/x-httpd-php3 .php3
    AddType application/x-httpd-php-source .phps
    AddType application/x-httpd-php4 .php4 .php .htm .html <==like here
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    4
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by aarongb:
    You can set mime type in httpd.conf to read .html or .htm files as php files, and then all html files will have to be interpreted through php. Why can't you just name your files .php, .php3, .php4, or .phtml?

    [/quote]

    Thanks for that. I'll gve it a try. I want to do it that way for a couple of reasons.
    Firstly, I'm playing with the idea of using PHP to build my site on my local Linux box but then using wget to to produce a copy of my site as pure HTML as my ISP doesn't have PHP. This gives me some of the advantages of PHP without the server side processing.

    The second reason is that I want my first page, the one the browser picks up without being told, (index.html) to be PHP.


    Cheers..

    Andy
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 1999
    Location
    Ann Arbor, MI USA
    Posts
    6
    Rep Power
    0
    You can also do this in .htaccess if you only want some .html files passed to PHP.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    1
    Rep Power
    0
    >The second reason is that I want my first
    >page, the one the browser picks up without
    >being told, (index.html) to be PHP.

    The cleaner way:
    1. have access to Apache configuration file (in my case: /etc/httpd/conf/srm.conf)
    2. locate the line starting with DirectoryIndex
    3. change the above line adding " index.php3" (w/o double quotes) at the end (mine reads "DirectoryIndex index.html index.htm index.shtml index.cgi index.php3 index.wml" -- again w/o quotes)
    4. in your starting web directory, be sure you have your index.php3 file and you deleted index.html file

    that's all

Similar Threads

  1. Apache 2 and PHP 4
    By stanley1610 in forum Apache Development
    Replies: 2
    Last Post: February 12th, 2004, 08:20 PM
  2. php for apache
    By wannabe in forum Beginner Programming
    Replies: 3
    Last Post: February 6th, 2004, 02:28 PM
  3. PHP -> system commands
    By Tantalus in forum PHP Development
    Replies: 1
    Last Post: January 28th, 2004, 10:51 AM
  4. Can PHP interpret Apache Directory Protection?
    By xpatriot in forum PHP Development
    Replies: 1
    Last Post: January 25th, 2004, 01:51 PM
  5. Apache and Php, php doesn't work
    By klaas in forum Apache Development
    Replies: 0
    Last Post: January 19th, 2004, 06:44 AM

IMN logo majestic logo threadwatch logo seochat tools logo