通过.htaccess文件为所有PHP脚本设置HTTP头 [英] Set HTTP header for all PHP scripts via .htaccess file

查看:116
本文介绍了通过.htaccess文件为所有PHP脚本设置HTTP头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的一个项目中编写了所有PHP程序的相同行。是否可以在.htaccess目录下执行此操作?如何?



PHP代码:

 标题('Content-类型:application / xhtml + xml; charset = utf-8'); 
标题(Cache-Control:no-transform);

感谢任何帮助。
最好的问候。



Yusuf Akyol

解决方案

你想用.htaccess(或Apache配置)这样做,你可以使用 Apache模块mod_headers ,如下所示:

 标题集缓存控制no-transform
标题集Content-Typeapplication / xhtml + xml; charset = utf-8

htaccess set header 为您提供了更多例子。


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

解决方案

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.

这篇关于通过.htaccess文件为所有PHP脚本设置HTTP头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆