views:

124

answers:

2

Hi to all gurus,

I code same lines all PHP programs at one of my projects. Is it possible to do this at .htaccess for a directory? And how?

PHP codes:

Header('Content-Type: application/xhtml+xml; charset=utf-8');
Header("Cache-Control: no-transform");

Thanks any help. Best regards.

Yusuf Akyol

+2  A: 

For the content type you use AddType from mod_mime. Assuming all your files have .php extensions:

AddType application/xhtml+xml .php

Caching is set in mod_expires, but you need mod_headers to set Cache-Control:

<FilesMatch "\.php$">
    Header set Cache-Control "no-transform"
</FilesMatch>
robertc
all of you... best regards...Best regards.
thanks too much all of you... best regards...Best regards.
A: 

If you want to do this with .htaccess (or in Apache config), you can use Apache module mod_headers, like this:

Header set Cache-Control "no-transform"
Header set Content-Type "application/xhtml+xml; charset=utf-8"

A search on htaccess set header gives you many more examples of this.

Piskvor
Won't this will set all files to be application/xhtml+xml, including images, javascript and stylesheets?
robertc
thanks too much all of you... best regards...Best regards.
Hi,Is it possible send a complete .htaccess codes for these? My htaccess has only these codes:<FilesMatch "\.php$"> Header set Cache-Control "no-transform" Header set Content-Type "application/xhtml+xml; charset=utf-8"</FilesMatch>I think I had to do more. Because I get error.Best regards.
@robertc: you are right; the OP said "for directory", so this would apply to all files in the directory.
Piskvor
@unknown (google): Looks OK to me, this should *be* the whole .htaccess code. Do you have mod_headers installed and enabled?Also, you get *an error*. That doesn't tell us very much, please be more specific - what kind of error? Also, what error is shown for this in the Apache error log?
Piskvor
Hi,I enabled mod_headers. Now everything is OK.Thanks again and again.Best regards.
@unknown (google): You're welcome. If this solved your problem, mark the answer "accepted" (the checkbox below the answer's score).
Piskvor