试图通过服务访问我的本地主机并获得301错误?

时间:2012-06-12 14:25:35

标签: php json web-services localhost

enter image description here我试图访问我的localhost即localhost / app并尝试在json中返回一些数据,这是php脚本

<?php


 header('Access-Control-Allow-Origin: *'); 

//test if a post request came


if(isset($_POST)) {


    //return a json request

    $contactDetails = array(
  "email" => "some@some.com",
  "twitter" => "@example",

);

echo json_encode($contactDetails);



 }


?>

这个php文件位于index.php

我试图使用localhost / app页面访问此页面,但我在firebug中遇到301错误,我不知道为什么,任何帮助表示赞赏

它在网络浏览器上运行,但在我尝试从其他地方请求信息时却没有

1 个答案:

答案 0 :(得分:1)

您是否尝试从外部(即实时)网站访问localhost网址?该网站无法访问您的本地主机,除非您已经提供了公共IP,我假设您没有。