Forum Moderators: phranque
I am switching my left hand nav bar to show up as a php include to simplify site updates and would like to keep the .htm extensions. I use Front Page to create and maintain my web and then FTP my files to the server. No Frontpage extensions. I would rename my files to .php but FP loses alot of functionality when dealing with .php files.
My .htaccess file begins like this:
---------------------------------------------------------------------------------
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 www.example.com
AuthUserFile /var/chroot/home/content/b/o/w/bowltrain/html/_vti_pvt/service.pwd
AuthGroupFile /var/chroot/home/content/b/o/w/bowltrain/html/_vti_pvt/service.grp
----------------------------------------------------------------------------------
I have tried adding the following statements to the bottom of my .htaccess with the results listed.
A.
AddType application/x-httpd-php .htm .html
Does not parse php in my test.htm file
correctly displays my test.php file
goes to a download screen when I access my main page (index.html)
B.
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
Does not parse php in my test.htm file
correctly displays my test.php file
goes to a download screen when I access my main page (index.html)
(same as above)
C.
AddType x-httpd-php .php .htm .html
AddHandler application/x-httpd-php .php .htm .html
Does not parse php in my test.htm file
goes to a download screen when I load test.php
goes to a download screen when I access my main page (index.html)
D.
RemoveHandler .html .htm
AddHandler application/x-httpd-php .php .htm .html
Does not parse php in my test.htm file
goes to a download screen when I load test.php
goes to a download screen when I access my main page (index.html)
-----------------------------------------------------------------------------------
I am currently with Godaddy hosting on a shared server plan and cannot access the server .conf files or settings. This presents several questions:
a. Should I switch hosting companies? Godaddy has left a bad taste in my mouth. Is Godaddy ok? Is anyone else any different?
b. Should I switch to a virtual server so I can access the .conf files?
To sum up, my three questions are these:
1. Can anyone tell me what I need to do, with my current host, to get .htm files to parse as .php?
2. Do I need to upgrade to virtual hosting to do what I want?
3. If I decide to upgrade to virtual hosting, should I find a new company or is Godaddy ok?
If your still reading this, I thank you now for the time you've invested in my problem. Any more time you spend giving a response will be even more greatly appreciated.
[edited by: eelixduppy at 7:07 am (utc) on Jan. 24, 2008]
[edit reason] example.com [/edit]
I use Front Page to create and maintain my web and then FTP my files to the server. No Frontpage extensions.
My .htaccess file begins like this: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 www.example.com
AuthUserFile /var/chroot/home/content/b/o/w/bowltrain/html/_vti_pvt/service.pwd
AuthGroupFile /var/chroot/home/content/b/o/w/bowltrain/html/_vti_pvt/service.grp
I had wondered what those entries were for.
I deleted them and retried the four entries from above, still with no luck.
I suspect my problem is in the httpd.conf file settings. But since I'm on a shared server I don't have access to that file.
Can I override those settings by placing a file in my folder, similar to doing that with .htaccess?
Or do I need to bite the bullet and move to a virtual server so I can access that file?
Or is there another way out?
You really don't need your own server to manage unless it's otherwise warranted; plenty of people parse .html files for php with shared hosted, though how it's done exactly can vary from one host to another depending on their configuration.
This is what's working for me now, with one hosting account:
AddHandler application/x-httpd-php .html .php .htm
Best thing: check with the host about disabling FP extensions for the site (it's enabled when the site is set up) and also ask them how to do the html/php thing on their system. If tech support doesn't know, ask them to escalate it to 2nd level support.
For example, the code posted above by Marcia is totally invalid -- But it often works!
Do not confuse the AddHandler and AddType directives like the PHP authors did -- Look them up in the Apache mod_mime documentation [httpd.apache.org] -- They are completely different, and require different parameters.
AddType declares a MIME-type, so that Apache can send the Content-Type response header to the client. It takes a MIME-type and one or more file extensions as arguments:
AddType text/html .php
AddHandler server-parsed .php
So either experiment with this and other suggestions, or ask your host as suggested above.
Jim
JDMorgan
If I'm understanding correctly neither code example you gave should work.
--------------------------
the "AddType text/html .php" seems to add a .php file to the "text/html" mime type
is that line of thinking correct?
--------------------------
"AddHandler server-parsed .php" seems to tell the server to parse files with the ext of .php
how about that one? is line of thinking B correct?
---------------------------
I've spoken with Godaddy tech support with no luck. I've opened an account with another hosting company with a slightly different setup that let's me see stuff I couldn't see at the Godaddy,(am I ok mentioning these hosts? not trying to spam or defam)
I've spoken with the new host's tech support with no success as of yet.
I think that
AddType text/hmtl .php
tells Apache to put 'text/html' in the header for clients as the content-type value and
AddHandler server-parsed .php
tells Apache to parse as server side script files marked .php, if I am right then you probably want a bit of a combination of 'B' & 'C' with the addition of small change to something Jim gave us:
RemoveHandler .html .htm
AddHandler server-parsed .htm .html
AddType x-httpd-php .php .htm .html
AddHandler application/x-httpd-php .php .htm .html
and you may or may not need to put '.php' on simile of next line because that should be in the httpd.conf file - don't be shy and correct me...
AddHandler application/x-httpd-php .php .htm .html
I hope that helps,
robsoles.
But you're wanting to also parse html files for embedded php code, and so "by the book" would want to add .html to the AddHandler filetype string.
Unfortunately, as I said above, PHP did not go "by the book" in interfacing to the Apache API, and your problems are the legacy of that mistake/decision. Since your problem is equal parts Apache and PHP and is a very common one, I'd also suggest you investigate some of the threads in our PHP forum turned up by this search [google.com] in addition to those you've read in this forum.
Jim
[edit] Clarify confusion from cross-posting. [/edit]
[edited by: jdMorgan at 1:20 pm (utc) on Jan. 25, 2008]
[webmasterworld.com...]
I tried all different combinations and different code and finally got it to stop happening by using the above, but at first was concerned that the site got hacked and was serving malware.
I was unfortunately unable to resolve this issue and have decided for the time being to use ssi and .shtml file ext.
I have had some other considerations present themselves and so will likely move to a virtual server where I have more control.
Thanks again for your input.
bowltrain