.htaccess and php

Discussion in 'Site & Server Administration' started by Jon12345, Jan 14, 2008.

  1. #1
    I have the following .htaccess file:

    AddHandler server-parsed .html
    AddHandler server-parsed .htm
    Code (markup):
    What does that actually mean? What do I need to add if I want to run html files as php?

    Thanks,

    Jon
     
    Jon12345, Jan 14, 2008 IP
  2. WebGeek182

    WebGeek182 Active Member

    Messages:
    510
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    95
    #2
    AddType application/x-httpd-php .htm .html
    Code (markup):
    Add this to your .htaccess to use a .htm or .html extension as php and the server will look for and process php code in your file. It can be handy. Just write the files like you would write any .php file.
     
    WebGeek182, Jan 14, 2008 IP
  3. Richie_Ni

    Richie_Ni Illustrious Member

    Messages:
    10,721
    Likes Received:
    1,175
    Best Answers:
    0
    Trophy Points:
    410
    #3
    This line means that all files ending in .html in your directory and every directory in your site will be parsed by the server looking for server-side includes.
     
    Richie_Ni, Jan 14, 2008 IP
  4. Jon12345

    Jon12345 Peon

    Messages:
    599
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    So is php considered a server-side include?

    Oh, and is it on a directory based level? The current .htaccess is in the root folder. Do I need another one in /myfolder if the html file is in there?
     
    Jon12345, Jan 14, 2008 IP
  5. WebGeek182

    WebGeek182 Active Member

    Messages:
    510
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    95
    #5
    Sorry...I slightly misread your post, and edited my response accordingly. PHP is not a server side include, although you can use includes in php. You only need one .htaccess in your public root. Any others you place in subdirectories will override the main one.
     
    WebGeek182, Jan 14, 2008 IP
  6. LawnchairLarry

    LawnchairLarry Well-Known Member

    Messages:
    318
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    118
    #6
    WebGeek182, that's a nice and helpful article you wrote on this topic and its effects!
     
    LawnchairLarry, Jan 18, 2008 IP
  7. WebGeek182

    WebGeek182 Active Member

    Messages:
    510
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    95
    #7
    Thanks! It's a simple fix...considering the problems people deal with because of it, it's kindof surprising that they don't use the solution I mentioned as a default on server installs.
     
    WebGeek182, Jan 18, 2008 IP