This seems a bit complex, do you have any thoughts as to why I can't open my htm pages after adding the "AddType application/x-httpd-php .php .htm .html" to my htaccess file? =)
Main Topics
Browse All TopicsThanks in advance for your help.
I am aware of 1 way to execute php code within .htm files
place this line in the .htacess file
AddType application/x-httpd-php .php .htm .html
There are 2 things with this that is giving me problems
(1) when I do this, it process all my .htm files (my entire site) through the php preprocessor causing some performance issues.
(2) **Another problem is after I add the line to the .htaccess file, I can't seem to open my .htm files correctly- a pop comes up and asks me if I want to download the file.**
I can live with the performance issue, but is there a way to accomplish this goal without changing file extensions and have everything run properly respective to point number (2) above? Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi Neester,
Oh when I say open, I simply mean visit through my browser. I.e. after adding that line to the htaccess file, I go to my browser and enter my website page url (htm file extension) and click on "go", my htm page doesn't open- instead a pop up dialog comes up asking me if I want to open or save to my desktop the htm file. I hope that makes sense.
Here is my htaccess file with certain info modified for privacy reasons:
~~~~~~~~~~~~~~~~~~~~~~~~~~
# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName mydomain.com
AuthUserFile /homepages/5/123456789/htd
AuthGroupFile /homepages/5/123456789/htd
AddHandler server-parsed .html .htm
AddType application/x-httpd-php .php .htm .html
~~~~~~~~~~~~~~~~~~~~~~~~~~
So basically once I add the line "AddType application/x-httpd-php .php .htm .html " this problem occurs. But I need some way to execute php scripts within htm files. The primary reason is for search engine concerns and that I already have many links point into this file with the htm ending and do not want to change it to php. I hope that clarifies it. Please feel free to let me know if you have any other questions. Thanks a lot. As an act of goodwill I have increased the point count to 100.
Sorry for the long delay, I restored a backup copy of my htaccess file and everything seemed to be working fine again. I don't really know how the files were different but it worked. Thanks for your help. I will be closing this question and refunding the points unless there are any objections. Sorry for the inconvenience.
Business Accounts
Answer for Membership
by: neesterPosted on 2005-06-14 at 17:53:25ID: 14217285
You could simply use HTACCESS to trick the user into thinking its a HTML file, when its really a PHP file.
-9]+).html $ test.php
erentpage_ abasdaljd8 9werhfsdf. html
erentpage_ 129837hasd f8.html erentpage_ a.html
-9]+).html $ test.php?input=$1
ie.
have the file on your server as: "test.php"
Add this to your HTACCESS
rewriteengine on
rewriterule ^test.html$ test.php
that will mean, if you goto www.yoursite.com/test.html
they will really be opening test.php
you can even do this
rewriterule ^totaldifferentpage_([A-z0
Which has some REGEX in there.
Which means if you goto:
www.yoursite.com/totaldiff
it will load test.php
so will:
www.yoursite.com/totaldiff
and
www.yoursite.com/totaldiff
If you want to use that extra bit of data (the random stuff)
have this in the REGEX:
rewriterule ^totaldifferentpage_([A-z0
now test.php has a GET input, with that random data between the _ and the .html
:)