To administer your WestHost account, please enter your
Domain Name or Server Manager Username.

WestHost: Professional Website Hosting Company








Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Junior Member
    Join Date
    Sep 2007
    Posts
    2

    Default Executing PHP in HTML Files

    Being new to PHP (and all things web-programming related) I would appreciate your advice.

    I would prefer to allow .html files to be able to execute PHP scripts, rather than use the .php extension. I understand I can accomplish this by modifying .htaccess by adding this line:

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

    Is this correct? And are there any disadvantages to modifying .htaccess in this way, especially in terms of security?

    Thanks in advance -

    Ted

  2. #2
    Moderator wildjokerdesign's Avatar
    Join Date
    Jun 2003
    Location
    Kansas City Mo
    Posts
    5,687

    Default

    I would suggest not doing it. May I ask why you want to do this?
    Shawn
    Please remember your charity of choice: http://www.redcross.org

    Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson

  3. #3
    Junior Member
    Join Date
    Sep 2007
    Posts
    2

    Default

    Quote Originally Posted by wildjokerdesign
    I would suggest not doing it. May I ask why you want to do this?
    Partly as a matter of appearance and partly to not make conspicuous that a procedure might run based on choices in a form. My instincts tell me it may be unwise. Can you elaborate on why you would not do it?

    Thanks -
    Ted

  4. #4
    Moderator wildjokerdesign's Avatar
    Join Date
    Jun 2003
    Location
    Kansas City Mo
    Posts
    5,687

    Default

    I wouldn't do it simply because it breaks the normal procedure of how things work. I see no problem with the .php extension and folks are used to it. Look at the forum here. Almost every forum out there uses php along with the majority of other popular scripts run now for web sites. The general public is used to seeing it. All forms have to run through some type of "procedure". It really is not going to help you from a security standpoint to try and hide that it is a php script. It is much better to choose secure scripts.

    Yes...
    Code:
    AddType application/x-httpd-php .html .htm
    Should work in a .htaccess file. Remember that using .htacces can put added strain on the server.
    Shawn
    Please remember your charity of choice: http://www.redcross.org

    Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson

  5. #5
    Senior Member jalal's Avatar
    Join Date
    May 2003
    Location
    Germany
    Posts
    1,377

    Default

    Ted, why do you think it is unwise?

    And as Shawn mentions, using .htaccess is a performance hit. If you do decide to go ahead it is better to put the code into your httpd.conf file and restart Apache.

  6. #6

    Default

    Ted,
    When I moved my site here, I switched to using php includes for navigation and other situations. I didn't want to rename all my html files and do redirects, and placed the directive in Apache as jalal says. My site runs fine, it's a heckuva lot faster than on my old host. If you already have html pages, it won't be a problem. But if you are starting a site from scratch, there's no reason not to use PHP exclusively.

  7. #7
    Junior Member
    Join Date
    Mar 2008
    Posts
    1

    Cool doesn't work

    I am trying to do the same thing - the reason is that our site was built with .html file extensions and has good google rankings for the pages. We need to add some PHP code to our pages, however, and renaming hundreds of .html pages as .php will be tedious and will hurt our google rankings.

    That said, we tried
    AddType application/x-httpd-php .html
    in both the apache configuration file and as an .htaccess file and it didn't work in either case. Instead, it now causes the browser to prompt to download .html files.

    Any ideas???

  8. #8
    Moderator wildjokerdesign's Avatar
    Join Date
    Jun 2003
    Location
    Kansas City Mo
    Posts
    5,687

    Default

    It should work. When you added the directive to your httpd.conf file did you restart the account via the Site Manager?
    Shawn
    Please remember your charity of choice: http://www.redcross.org

    Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson

  9. #9
    Junior Member
    Join Date
    Jun 2008
    Posts
    1

    Default

    Any resolution to this issue? I am encountering the same problem. I have installed the latest version of PHP via the site manager -- php files open file on their own, but trying to run php on an html page fails.

    Where is the apache configuration file (httpd.conf) located? I have attempted making modifications to the .htaccess file, but every variation I make either does nothing or prompts a download instead of opening the web page.

    Thanks for any insight!

  10. #10

    Default

    Directory Location: /etc/httpd/conf/

Similar Threads

  1. exec(), popen(), etc. for executing a php script
    By Tlanuwa in forum PHP / MySQL
    Replies: 3
    Last Post: 09-18-2006, 06:25 PM
  2. Best HTML PHP SQL Editor
    By AndreyPopov in forum PHP / MySQL
    Replies: 3
    Last Post: 01-12-2005, 08:38 PM
  3. Interpreting html files as php ... again
    By blakekr in forum General Discussion
    Replies: 1
    Last Post: 12-07-2004, 09:53 PM
  4. Replies: 2
    Last Post: 02-27-2004, 09:22 AM
  5. Parsing HTML Files through PHP
    By rl in forum PHP / MySQL
    Replies: 6
    Last Post: 12-21-2003, 11:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •