如何将我的htaccess代码转换为php头文件 [英] How to convert my htaccess code to php header

查看:189
本文介绍了如何将我的htaccess代码转换为php头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的.htaccess中有这些代码行。



我的问题是这行代码在我的.htaccess中,我想把它放在我的php中。



  AddType应用程序/ xml .xml 

我想要做的就是将它转换为php标题有人知道该怎么做吗? .rss
Header add Access-Control-Allow-Origin*
Header add Access-Control-Allow-Headersorigin,x-requested-with,content-type
Header add Access-Control-Allow-MethodsPUT,GET,POST,DELETE,OPTIONS


解决方案

你甚至试图自己实现它,或者阅读 http:/ /php.net/manual/en/function.header.php



在文件的第一个输出之前写下这些行。
应该做这项工作(虽然未经测试):

 <?php 
// ...
标题('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Headers:origin,x-requested-with,content-type');
header('Access-Control-Allow-Methods:PUT,GET,POST,DELETE,OPTIONS');
?>


I have these lines of code in my .htaccess.

My problem is is this line of code is in my .htaccess i want to put it in my php.

I want to do is convert it to php header does anyone know how to do it?

AddType application/xml .xml .rss
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"

解决方案

Did you even try to implement that yourself or read at http://php.net/manual/en/function.header.php?

Write those lines before the first output of the file.
Should do the job (although untested):

<?php
// ...
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: origin, x-requested-with, content-type');
header('Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS');
?>

这篇关于如何将我的htaccess代码转换为php头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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