Reputation: 619
I have set my nginx server to redirect all traffic from http to https. Now I need to have one url accessible from http. Here is my nginx config:
server {
listen 80 default;
server_name www.example.com example.com;
location /example_page/ {
return 301 http://$server_name/example_page/;
}
rewrite ^ https://$server_name$request_uri? permanent;
}
But this won't work.
Upvotes: 1
Views: 1595
Reputation: 2675
You can define rules for whole site and excluded url:
server {
server_name example.com;
listen 80;
...
# redirect any http url to https
location / {
return 301 https://$server_name$request_uri;
}
# but no redirect for this particular location:
location /example_page/ {
# usual site rules here (php handler etc)
}
}
Upvotes: 1