filename.php.html is parsing as PHP and I don't want it to

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

filename.php.html is parsing as PHP and I don't want it to

Post by RobertGonzalez »

I just ran a PHPDocumentor process on an application and the generated HTML pages are now made using an XML declaration at the top of the file. Not that this is that important, except for the fact that for some reason my local apache server wants to parse .php.html names files as PHP. This results in parse errors because of the opening <?xml in the file.

Does anyone know how I go about telling apache to just treat those files as HTML instead of parsing them as PHP?

I am not about to chance every file that is generated after every generation so I really need to handle this at the server level.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: filename.php.html is parsing as PHP and I don't want it to

Post by Eran »

In your apache configuration file (httpd.conf) you will find something similar to 'AddType application/x-httpd-php .php' under <IFModule mime_module>
You might try adding a line like: 'AddType text/html .php.html', though I fear it will only recognize the extension after the first dot.
Don't forget to restart your server after you save changes
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: filename.php.html is parsing as PHP and I don't want it to

Post by RobertGonzalez »

Here's the thing... I want .php,html files to be read as HTML. Right now they are read as PHP for some reason (and I cannot figure out why).

There is no AddType handler anywhere in my apache conf files that would tell it to do that.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: filename.php.html is parsing as PHP and I don't want it to

Post by Eran »

Did you try adding the addtype handler i suggested? you might to read about it more here - http://httpd.apache.org/docs/2.0/mod/mo ... ml#addtype
Apparently it can be run from htaccess directly so you might want to set it up only for the directories that need it instead of inside the apache config.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: filename.php.html is parsing as PHP and I don't want it to

Post by Benjamin »

Turn off short tag support.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: filename.php.html is parsing as PHP and I don't want it to

Post by RobertGonzalez »

I will sort this out tomorrow with the AddType declaration to test it.

@astions: short tags are off.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: filename.php.html is parsing as PHP and I don't want it to

Post by RobertGonzalez »

This has to do with mod_negotiation I believe. I am reading more, like how to turn it off, but for now, I think I found it.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: filename.php.html is parsing as PHP and I don't want it to

Post by RobertGonzalez »

And for the record, adding the AddType line did not work.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: filename.php.html is parsing as PHP and I don't want it to

Post by Benjamin »

Everah wrote:This results in parse errors because of the opening <?xml in the file.
I don't understand how that could happen if short tags are off. <?xml != <?php
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: filename.php.html is parsing as PHP and I don't want it to

Post by RobertGonzalez »

Yeah, I'm an idiot.

I turned of Short Open Tags on all of my machines everywhere whenever I install PHP. But apparently I did not on this one. Thanks astions. That was totally n00bish of me.

It is fixed. And now I feel hella stupid. :oops:
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: filename.php.html is parsing as PHP and I don't want it to

Post by Benjamin »

Hey at least it's fixed.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: filename.php.html is parsing as PHP and I don't want it to

Post by Kieran Huggins »

don't blame yourself!

Image

They come at night with their electronic keyboards, messing with your config files.

Set traps, you'll find them in the morning.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: filename.php.html is parsing as PHP and I don't want it to

Post by RobertGonzalez »

Frick, that was funny Kieran. One of these days I hope to be that cool.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: filename.php.html is parsing as PHP and I don't want it to

Post by John Cartwright »

Kieran for Governor++
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: filename.php.html is parsing as PHP and I don't want it to

Post by RobertGonzalez »

Jcart wrote:Kieran for Governor++
I would so vote for him.
Post Reply