我希望某个页面 example.php 在通过 SSL 访问时重定向到非 SSL 版本。我应该查看哪种类型的重写?
答案1
可以使用以下代码...
server {
listen 443 ssl;
server_name domainname.com;
ssl_certificate /path/to/cert.crt;
ssl_certificate_key /path/to/cert.key;
location = /path/to/example.php {
return 301 http://$host$request_uri;
}
# other directives here
}
server {
listen 80;
server_name domainname.com;
location = /path/to/example.php {
# include directives to process PHP here
}
# return all other requests to SSL
location / {
return 301 https://$host$request_uri;
}
}