I'm trying to redirect all HTTP traffic to HTTPS. The web server I'm using is nginx. This is the server block I'm using to do the redirect.
server {
listen 80;
rewrite ^ https://$server_name$request_uri? permanent;
}
This successfully redirects URLs like http://localhost
to https://localhost
. However, for URLs like http://localhost/table/
I get redirected to https://table
which is incorrect. I would like it to re-direct to https://localhost/table/
Any help would be much appreciated.
Update:
It seems that the rewrite scheme has a problem with trailing slashes. For example, http://localhost/table
gets correctly redirected but http://localhost/table/
does not.