简体   繁体   中英

Nginx: Location header sent by PHP redirects withoung changing domain

I'm having a strange problem here and can't figure the cause. I have a php-script on an nginx server which triggers a redirect to a different (sub)domain on the same server:

For instance: foo.domain.com/redirect.php header("Status:301"); header("location:http://www.domain.com/new_url/");

The result is that I'm getting redirected to: foo.domain.com/new_url

The domain doesn't change at all although my response headers look fine .

Any ideas?

Ok, I finally found the cause for my troubles. Neither Nginx, nor PHP caused the issues. My webservers are behind a loadbalancer running with Pound.

Pound has a feature to rewrite domains inside header redirects (enabled by default). We now turned this feature off and all redirects finally work as expected!

Check your containing your site in an iframe,

Some hosts can do this if its free hosting, all so some domains setup allows the site to be contained in an iframe witch would cause the properly your describing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM