So it dawned on me that I could pretty safely set the MIME type for Opera or any Gecko based any browser that claims it can handle application/xhtml+xml in its HTTP_ACCEPT.
For now I have limited this to my home IP address.
All it took was a little PHP… and whaddaya know, I just happen to be able to write a little PHP (very little, but it’s a start)
Here’s what I did. I think it is pretty straight forward, but I’ve added copious comments. It’s pretty slick. I love PHP.
I created a separate text file with PHP code to set MIME type based on IP and HTTP_ACCEPT.
[update: this entry has been editing/updated since the original. See later entries for explanation]
†
{ 2 comments }
Hi Timothy,
I don’t have a static IP so I can’t experiment with ‘application/xhtml+xml’… but I found your tip at the bottom of the listing very interesting:
// You may want to add // // AddType application/x-httpd-php .html // // to the .htaccess to have all .html files treated as PHP
I have a local WAMP installation and just changed the PHP line in the httpd.conf file to
AddType application/x-httpd-php .php .html .php3
After restarting the Apache (1.3.26) server, however, I ran into something rather fancy… the little script below gets executed when I browse to http://localhost/phptest.php:
<html> <body> <?PHP echo phpinfo(); ?> </body> </html>
in IE 6 as well as in Moz 1.1.
But when I browse to http://localhost/phptest.html
<html> <body> <?PHP echo phpinfo(); ?> </body> </html>
I only see a blank page in both the browsers!!
When I “view source” I get the pure code - exactly as shown above.
To verify there wasn’t happening something odd, I changed it to
<html> <body> does not work ?!? <?PHP echo phpinfo(); ?> </body> </html>
which displays just “does not work ?!?”, of course, on the page in both the browsers.
Do you happen to know what would prevent the server from executing the code?! What could be wrong - or missing - in httpd.conf ?
As I said: all files with extension .php or .php3 are executed just fine… Thanks in advance for any hint ! :)
Gerhard
The file extension is .php in the first file and is .html in the second. .html will have been set as a MIME type first (or before) and that may prevent any further mapping for that type. I don’t know the exact details, but you are probably trying to redefine a defined type (.html) and that would probably not be allowed.
Your welcome
Rodney
Comments on this entry are closed.