I'm using a php script to send users from mysite.com/id=123 to mysite.com/my-id-title
I could use .htaccess file to rewrite the URL (which is -of course the natural solution- but given that the replacement information for the url is not in the original parameter provided by the url, but requires a database query (as you can see in the example) I cannot do that with just mod_rewrite. And to make matters more difficult, I do not have access to Apache, I can just use the .htaccess.
So, I thought, as a workaround, to generate a rule though php, which does work using header('Location:'.$reenvioA);
The problem is that PHP generates a 302 response code, instead of 200. A 200 response is what I need to create a sitemap and for SEO reasons.
So, in order to prevent that, I thought about telling php that I want a 200 code, so I force it.
I've tried quite a few ways:
header("HTTP/1.1 200 OK");
header('Location:'.$reenvioA);
Maybe forcing it before and after the Location header?
header("HTTP/1.1 200 OK");
header('Location:'.$reenvioA);
header("HTTP/1.1 200 OK");
And then I've tried doing it using their optional arguments:
header('Location:'.$reenvioA, false, 200);
Maybe just letting the second argument remain true?
header('Location:'.$reenvioA, true, 200);
And then just setting the variable with the response itself:
header('Location:'.$reenvioA);
http_response_code(200);
So far, none has worked, because as soon as I forced the response, the page won't load. It seems that php won't fetch the page, even when the response code is set after header(Location:url).
What can I do?