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
Results 1 to 10 of 11
Thread: Executing PHP in HTML Files
-
09-12-2007, 12:13 PM #1Junior Member
- Join Date
- Sep 2007
- Posts
- 2
Executing PHP in HTML Files
-
09-12-2007, 12:20 PM #2
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
-
09-12-2007, 02:17 PM #3Junior Member
- Join Date
- Sep 2007
- Posts
- 2
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?
Originally Posted by wildjokerdesign
Thanks -
Ted
-
09-12-2007, 03:46 PM #4
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...
Should work in a .htaccess file. Remember that using .htacces can put added strain on the server.Code:AddType application/x-httpd-php .html .htm
Shawn
Please remember your charity of choice: http://www.redcross.org
Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson
-
09-13-2007, 01:46 AM #5
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.
-
10-10-2007, 02:28 PM #6Member
- Join Date
- Aug 2007
- Posts
- 38
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.
-
03-24-2008, 02:54 PM #7Junior Member
- Join Date
- Mar 2008
- Posts
- 1
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???
-
03-24-2008, 03:08 PM #8
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
-
06-25-2008, 01:16 PM #9Junior Member
- Join Date
- Jun 2008
- Posts
- 1
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!
-
06-26-2008, 05:50 AM #10Member
- Join Date
- Aug 2007
- Posts
- 38
Directory Location: /etc/httpd/conf/
Similar Threads
-
exec(), popen(), etc. for executing a php script
By Tlanuwa in forum PHP / MySQLReplies: 3Last Post: 09-18-2006, 06:25 PM -
Best HTML PHP SQL Editor
By AndreyPopov in forum PHP / MySQLReplies: 3Last Post: 01-12-2005, 08:38 PM -
Interpreting html files as php ... again
By blakekr in forum General DiscussionReplies: 1Last Post: 12-07-2004, 09:53 PM -
perlfect search and indexing php files + a php wrapper
By gnossos in forum PHP / MySQLReplies: 2Last Post: 02-27-2004, 09:22 AM -
Parsing HTML Files through PHP
By rl in forum PHP / MySQLReplies: 6Last Post: 12-21-2003, 11:59 PM
Reply With Quote