views:

261

answers:

2

I have a cakephp 1.2 app (1.2.2.8120) and I am trying to change the mime-type for Japanese cell phones on certain pages with this one line of code in the app/webroot/.htaccess file:

AddType application/xhtml+xml .xhtml

This works for .xhtml files uploaded directly to the webroot folder, but regular cakephp pages don't work.

I have tried to add the same .htaccess line of code to the app/.htaccess and /.htaccess files but it did not work. I also added the line:

header('Content-type: xhtml+xml');

to the beforeFilter() method of the app_controller, but that also did not work.

Thanks ahead of time for any help you can provide.

A: 

The problem is that there's no file involved with an .xhtml extension in a normal Cake app, so Apache can't identify the type. What's actually invoked is the webroot/index.php file, so you may want to set the type for .php files. I think I've seen this fail before though.

You could also try using DefaultType application/xhtml+xml.

Setting a PHP header() first thing in the default.ctp layout might be the best option though.
Using the RequestHandler Components respondAs() to set the header should be the best option. AFAIA that's equivalent to an Apache header.

deceze
A: 

See http://www.pagebakers.nl/2007/06/05/using-json-in-cakephp-12/

It looks like Cake abstracts content-type headers. You just need to switch the JSON content-type for the XHTML one.

David Dorward