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程序的相同行。是否可以在.htaccess中为目录执行此操作?如何?
PHP codes:
PHP代码:
Header('Content-Type: application/xhtml+xml; charset=utf-8');
Header("Cache-Control: no-transform");
Thanks any help. Best regards.
谢谢你的帮助。最好的祝福。
Yusuf Akyol
优素福Akyol
2 个解决方案
#1
7
If you want to do this with .htaccess (or in Apache config), you can use Apache module mod_headers, like this:
如果你想用.htaccess(或在Apache配置中)这样做,你可以使用Apache模块mod_headers,如下所示:
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.
搜索htaccess set header会为您提供更多示例。
#2
4
For the content type you use AddType from mod_mime. Assuming all your files have .php
extensions:
对于内容类型,您可以使用mod_mime中的AddType。假设您的所有文件都有.php扩展名:
AddType application/xhtml+xml .php
Caching is set in mod_expires, but you need mod_headers to set Cache-Control:
缓存在mod_expires中设置,但您需要mod_headers来设置Cache-Control:
<FilesMatch "\.php$">
Header set Cache-Control "no-transform"
</FilesMatch>
#1
7
If you want to do this with .htaccess (or in Apache config), you can use Apache module mod_headers, like this:
如果你想用.htaccess(或在Apache配置中)这样做,你可以使用Apache模块mod_headers,如下所示:
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.
搜索htaccess set header会为您提供更多示例。
#2
4
For the content type you use AddType from mod_mime. Assuming all your files have .php
extensions:
对于内容类型,您可以使用mod_mime中的AddType。假设您的所有文件都有.php扩展名:
AddType application/xhtml+xml .php
Caching is set in mod_expires, but you need mod_headers to set Cache-Control:
缓存在mod_expires中设置,但您需要mod_headers来设置Cache-Control:
<FilesMatch "\.php$">
Header set Cache-Control "no-transform"
</FilesMatch>