nginx improperly forwards to https, adds two trailing slashes when rewriting
- by Kevin
I'm using nginx as a proxy for a django project on mod_wsgi and to serve the static content.
I have two domain names for it: asdf-example.com and asdfexample.com. I want to use rewrites to redirect everything to www.asdf-example.com
They're not quite working the way they should:
asdf-example.com forwards to https:// www.asdf-example.com, which fails because I'm not using SSL. Though asdf-example.com/search forwards to http://....
asdfexample.com and www.asdfexample.com both forward to www.asdf-example.com//, which looks weird.
My config file:
server {
listen 80;
server_name asdf-example.com asdfexample.com;
if ($host ~* ^asdf-example\.com){
rewrite ^(.*)$ http://www.asdf-example.com/$1 permanent;
}
if ($host ~* ^asdfexample\.com){
rewrite ^(.*)$ http://www.asdf-example.com/$1 permanent;
}
if ($host ~* ^www\.asdfexample\.com){
rewrite ^(.*)$ http://www.asdf-example.com/$1 permanent;
}
...
Thanks