Jump to content
Froxlor Forum
  • 0

SSL Redirect


nicname

Question

At the Moment, SSL Redirects work this way:

 

<VirtualHost IP:80>
 ServerName domain.tld
 ServerAlias alias.domain.tld
 ServerAdmin admin@domain.tld
 Redirect  / https://domain.tld
</VirtualHost>

 

 

This works fine if you have set up your domain and your SSL cert etc right from the first place.

 

But there's a Problem when you had your website since some years and choose to change your site into an ssl only site afterwards.

 

Lets Pretend a user has folllowing bookmark:

 

http://domain/subpage

 

in this case the user would get redirected to:

 

https://domainsubpage

 

for an unexperienced user this could seem that the website is down.

 

 

a better way would be to use this:

<VirtualHost IP:80>
 ServerName domain.tld
 ServerAlias alias.domain.tld
 ServerAdmin admin@domain.tld
<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{HTTPS} off
 RewriteRule (.*) https://domain.tld%{REQUEST_URI}
</IfModule>
 Redirect  / https://domain.tld
</VirtualHost>

 

In this case the user woould be redirected to https://domain/subpage and if mod rewrite is not available, there is still the old call

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

According to the Lighty documentation this should work:

 

http://redmine.lighttpd.net/wiki/1/HowToRedirectHttpToHttps

 

 $HTTP["host"] =~ "domain.tld" {
   url.redirect = ( "^/(.*)" => "https://domain.tld/$1" )
   server.name                 = "domain.tld" 
 }

 

 

With nginx it should be:

server {
server_name  domain.tld;
location / {
     rewrite     ^(.*)   https://domain.tld$1 permanent;
   }
}

 

 

While i know that the lighty configuration works, i haven't tested the nginx one.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.



×
×
  • Create New...