SEO Redirects from h*p:// domain. tld to h*ps:// x domain. tld

Discussion in 'Installation/Configuration' started by A.Bauer, Aug 29, 2017.

  1. A.Bauer

    A.Bauer New Member

    Last edited: Aug 29, 2017
  2. HSorgYves

    HSorgYves Active Member HowtoForge Supporter

    Check "Rewrite HTTP to HTTPS" under Web Domain -> Redirect
  3. A.Bauer

    A.Bauer New Member

    Thanks for you reply. However, this is just what I'm doing right now. This adds a redirect from http to https, which is my 2nd point.

    I want to have a redirect from http://domain.tld to https://www.domain.tld in ONE step.

    PS: I edited my first post to make it a bit clearer
    Last edited: Aug 29, 2017
  4. HSorgYves

    HSorgYves Active Member HowtoForge Supporter

    Now I get your question. The SEO redirect is applied to both web sites, while the HTTP->HTTPS redirect is obviously only applied to the HTTP web site. So I guess it cannot be done in ISPConfig, not even by adding an Apache Directive (which would get applied to both websites again), without modifying server/conf/vhost.conf.master

    To do so, first copy the file to server/conf-custom/vhost.conf.master and then edit line 448:
    NEW: <tmpl_if name='rewrite_to_https' op='==' value='y'>
    NEW: RewriteRule ^(.*)$ https://<tmpl_var name='seo_redirect_target_domain'>$1 [R=301,NE,L]
    NEW: <tmpl_else>
    448: RewriteRule ^(.*)$ http<tmpl_if name='ssl_enabled'>s</tmpl_if>://<tmpl_var name='seo_redirect_target_domain'>$1 [R=301,NE,L]
    NEW: </tmpl_if>
    A.Bauer and Jesse Norell like this.
  5. A.Bauer

    A.Bauer New Member

    thanks for you reply!! I will try this and give feedback!

  6. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    You could do this in apache directives if you want (using mod_rewrite or a Redirect), but +HSorgYves solution is nice - seems like the correct solution to be included in a merge request, no? (@till ?)
  7. HSorgYves

    HSorgYves Active Member HowtoForge Supporter

    True @Jesse Norell , I first thought applying it to both sites would create a loop, but as we check for ^domain\.tld$ first, it works.
    So @A.Bauer you can also add the following two lines to your apache directives and disable both redirects in ISPConfig:
    RewriteCond %{HTTP_HOST} ^domain\.tld$ [NC]
    RewriteRule ^(.*)$ https://www.domain.tld$1 [R=301,NE,L]
  8. A.Bauer

    A.Bauer New Member

    @HSorgYves , your change works like a charm! I would love the have this in the next Patch of ISPconfig!
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    I've added it to the bugtracker.
  10. HSorgYves

    HSorgYves Active Member HowtoForge Supporter

    @till, I could commit it to the git, should I do so as pull request?

Share This Page