为什么我的网站认为$ http请求是跨域的?

In my website I'm calling to a php page at http://domain.com/angulartest/js/services/index.php

from a service in the same folder.

app.factory('vakmannen', ['$http', function($http) {
return $http.get('http://www.domain.com/angulartest/js/services/index.php')
.success(function(data) {
    return data;
})
.error(function(err) {
    return err;
}); 
}]);

and this is my php

<?php
header("Access-Control-Allow-Origin: http://www.domain.com/angulartest/");

$servername = "localhost";
$username = "XXXXX";
$password = "XXXXX";
$dbname = "XXXXX";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT * FROM XXXX";
$result = $conn->query($sql);
while($row = $result->fetch_array(MYSQL_ASSOC)) {
            $myArray[] = $row;
    }
    echo json_encode($myArray);
?> 

But every time the $http.get runs Firefox tells me the CORS header isn't right, I've tried it on Chrome too but to no avail.

Any help will be greatly appreciated!

If the angular app is in the same folder, you can use relative URLs. You can even remove the Access-Control-Allow-Origin header.

app.factory('vakmannen', ['$http', function($http) {
return $http.get('/angulartest/js/services/index.php')
.success(function(data) {
    return data;
})
.error(function(err) {
    return err;
}); 
}]);