I\'m in the process of moving a working apache/mod-php website to nginx/php-fpm.
Under Apache/mod-php, I could use header(\"Location: $url\");
to redire
The Location
header does not, by itself, trigger the browser to redirect. The redirect is actually triggered by an HTTP response code that is in the 3xx
series. w3c has explanations for all http response codes.
Apache automatically sees the Location
header in the response, and forces the response code to be 300-series if you haven't previously set a response code of your own. Nginx does not do this -- it expects you set the proper response code yourself.
You can force php to send a modified HTTP response code like this:
<?php
header("HTTP/1.0 301 Moved Permanently");
?>
...Then, of course, you'll need to be sure you still sent your Location
header after sending the HTTP/1.0...
line shown above.