Reputation: 21
Nginx is new to me. I'm currently redirecting http to https using the following.
if ($scheme = http) {
return 301 https://$server_name$request_uri;
}
How would I do the same except not redirect anything going to subfolder /abcd/ ? I've tried using location blocks, but it gives me a "too many redirects" error when loading the site.
Thanks for any help you can give.
Upvotes: 2
Views: 306
Reputation: 49772
The if
statement suggests that you are processing http
and https
requests in the same server
block. You need to use two server
blocks. This will remove the if
block and allow you to use simple location
blocks to handle the excluded directories.
For example:
server {
listen 80;
location /abcd/ {
...
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
...
}
Upvotes: 1