I'm trying to send a redirect using the Location header with PHP but my efforts have been in vain. Regardless of what I'm attempting with my code, I decided to try a test in which all that happens is the actual redirect, and it still fails. Here's the code:
<?php
error_reporting(E_ALL);
header("Location: http://www.google.pt", true, '301');
I have seen some similar questions posted here at stack overflow but most of the times it seems to be related with the generation of output before setting the headers, which seems clear that I'm not doing here. Here's what I get in the browser after the response, using safari.
I don't have any errors in my log nor does PHP seem to be generating any warnings whatsoever. What could be wrong?
Best.
Edit: Here's how I'm making the request:
$.ajax({
'url': '/api/test.php',
'type': 'GET',
});
And here are the details:
Edit: because the duplication flags: I can't return JavaScript, because this is supposed to be consumed by both a website and a mobile app. The mobile app does not run javascript.