Home > Backend Development > PHP Tutorial > PHP中如何防止外部恶意提交调用ajax接口_PHP

PHP中如何防止外部恶意提交调用ajax接口_PHP

WBOY
Release: 2016-05-27 10:34:25
Original
1142 people have browsed it

我们自己网站写好的ajax接口,如果给自己用,那就限定一下来路域名,判断一下来路即可。

代码如下:

//判断来路
if(!isset($_SERVER['HTTP_REFERER']) || !stripos($_SERVER['HTTP_REFERER'],'www.bitsCN.com')) {
 echo 'cann`t access';
 exit();
}

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template