http to https redirection

Discussion in 'General' started by neutrino, Mar 19, 2010.

  1. neutrino

    neutrino Member

    Hello,

    I'm currently trying to redirect the url http://mail.server.com to https://mail.server.com

    I've tried all the options in ISPCONFIG (no flag, R, L, RL) and none off them actually work, Firefox / IE / Opera, there is no browser that accepts the rewrite rule.

    The code produced by ispconfig is the next one :

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^mail.server.com [NC]
    RewriteRule ^/(.*)$ https://mail.server.com/$1 [R,L]


    What I want to do, is to replace the ISPconfig code with something that works like :

    RewriteEngine on
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]


    Problem is, each time I'll perform a change on the site, my code will be erased by the standard ispconfig code.

    How can I change this ? I suppose I have to change some master code of ISPconfig, but I don't really like that idea, because it always causes trouble when updating to a new version.

    Can a fix be expected in a future version of ISPconfig maybe ?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Just add the lines:

    RewriteEngine on
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

    in the apache directives field of the website settings and click on save.
     
  3. neutrino

    neutrino Member

    That works perfectly well, I forgot that option !

    Thanks a lot till :)
     
  4. Appie Thrasher

    Appie Thrasher Member HowtoForge Supporter

    Does this work for all or must I chance something in those lines?
    I want to use https://webmail.mydomain.com all the time somebody uses web-mail.
     
  5. Hans

    Hans Moderator ISPConfig Developer

    Yes that works, and also:

    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
     
  6. Appie Thrasher

    Appie Thrasher Member HowtoForge Supporter

    Witch one is the preferred way to do it?
     
  7. Unfaiir

    Unfaiir New Member

    Feature Request: ModRewrite Is Not Optimal For This

    Is there any chance that the option to make a whole site SSL only can be added to ISPConfig 3 in a future release?

    Having this written into the vhost file is not only the "proper" way to do it but also would be a performance gain:

    Code:
    <VirtualHost *:80>
       ServerName www.example.com
       Redirect permanent / https://example.com
    </VirtualHost>
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    No need to edit or create a vhost file as you can do this from within ispconfig. Go to the sites module, edit the website and go to the options tab and enter the following lines in the apache directives field:

    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    and press save.
     
  9. Unfaiir

    Unfaiir New Member

    That works too.

    I wasn't suggesting that anyone modify the vhost directly I'm just making a feature request for a site option that basically says "Hey ISPConfig, I want this entire site to be SSL only".

    Having that option would allow ISPConfig to then automatically write that very simple *:80 vhost entry, which not only handles the SSL only part, but also eliminates a full fledged *:80 vhost entry that never gets used but still has to get loaded into memory. This would also eliminate any need for adding any redirects by the user.

    Not a crucial feature request or anything, but it would be nice. :cool:
     
  10. lovendo

    lovendo New Member

    Up, that's a really good request. Any news?
     

Share This Page