nGinx - SSL - Force www in url
Now I want to force www to always be part of the URL so I currently have as the sites-available config:
force public http to http://www
server {
listen 80;
server_name example.com;
rewrite ^(.*) http://www.example.com$1 permanent;
}
server {
listen 80;
server_name
[……]
}
force secure https to https://www
server {
listen 443 ssl;
server_name example.com;
rewrite ^(.*) https://www.example.com$1 permanent;
}
server {
listen 443 ssl;
server_name
ssl_certificate /srv/ssl/
sslcertificatekey /srv/ssl/
[……]
}
But now all i get is "The connection was interrupted page".
Error logs show nothing, nginx restart produces no errors or warnings.
The SSL used www in the name during the key / crt generation.
Any ideas? Suggestions would be great.
As always thanks!
Dave
1 Reply
Does it still use .htaccess?
If so just add this into the .htaccess file (altered accordingly)
Redirect non-www urls to www
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.yoursite.com
RewriteRule (.*)