Cross domain issue in php

Use below code on the top of page with other domains URL.

<?php header(“Access-Control-Allow-Origin:”); ?>

If you want to add multiple cross domains add as follows:


$http_origin = $_SERVER[‘HTTP_ORIGIN’]; //To get current server¬† URL.
$urls=array(‘’,’’);¬† //Provide all other doamins as elements of array
header(“Access-Control-Allow-Origin: $http_origin”);



Posted in Php

Leave a Reply

Your email address will not be published. Required fields are marked *