Redirect Rule

Hello

I am running my djago application in nginx server. In my configuration I
redirect all http to https using the below settings

location / { rewrite ^/(.*) https://mydomain.com/$1 permanent; }

What i want is i need to redirect to all my http request to https
except
only one url like http://mydomain.com/x/y.

I tried

location ~* / {
rewrite ^/(.*) https://mydomain.com/$1 permanent;
}

location = mydomain.com/x/y {
rewrite ^/(.*) http://mydomain.com/$1 permanent;
}

But no luck.Can you please advice me what went wrong here.Really i am
struck
with this.

Thanks

Milin Korath

Hello!

On Sat, Jul 09, 2011 at 06:19:04PM +0530, milin korath wrote:

I tried

location ~* / {

There is no need to use regexp here, just normal “location /” will
do the same thing.

rewrite ^/(.*) https://mydomain.com/$1 permanent;

Something like

rewrite ^ https://mydomain.com$request_uri? permanent;

is a bit more effecient way to do the same thing.

}

location = mydomain.com/x/y {

You don’t need “mydomain.com” here, just “location = /x/y”.

rewrite ^/(.*) http://mydomain.com/$1 permanent;

And you don’t need redirect here, as it will create infinite loop
as long as this is config for http part of mydomain.com.

}

But no luck.Can you please advice me what went wrong here.Really i am struck
with this.

Bringing all of the above together gives something like this:

location / {
    rewrite ^ https://mydomain.com$request_uri? permanent;
}

location = /x/y {
    # ... process it right here
}

Maxim D.

Hi

Hello!

On Sat, Jul 09, 2011 at 09:41:42PM +0530, milin korath wrote:

Hi

location = /x/y {
# … process it right here
}
What should i need to write here.Sorry i am not familiar with nginx
directives …

If you want it to be served as static - just leave this block
empty. If you want to handle it with backend - write appropriate
proxy_pass/fastcgi_pass/… as in your https server.

Maxim D.

Hello
I tried
rewrite ^ https://mydomain.com$request_uri? permanent;


nginx mailing list
[email protected]
nginx Info Page