We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36667
    • 57 Posts
    Peter Falkenberg Brown Reply #1, 14 years, 9 months ago
    Hi All,

    [SOLVED: SEE BOTTOM OF POST]

    I searched for this answer, but didn't look at every search hit, so I hope I'm not being redundant.

    I'm trying to force an entire site to redirect to SSL *and* use friendly urls.

    This is in my web doc root .htaccess file:

    # For Friendly URLs
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

    # This doesn't preserve friendly urls, so it has to be fixed
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

    SSL works fine if it's typed in specifically, or linked to.
    But, when I go to a friendly url without SSL, it redirects to SSL correctly, but
    doesn't use the friendly url. It goes back to the index.php? syntax (with https).

    So somehow I have to combine them. Anyone know how to do that?
    I've been scouring the web to no avail.

    I'm using Evo.

    Thanks!

    Peter Brown

    [SOLVED]

    A friendly sysadmin helped me with this. He did two things:

    1. The SSL rewrite was placed above the friendly url rewrite
    2. The SSL rewrite had an [L] placed at the end of the line, to stop SSL processing there.

    The new one looks like this:

    # HTTPS goes first, with ending [L]
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]

    # For Friendly URLs
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

    It works like a charm.

    Ain't knowledge a wonderful thing?

    Peter
    [ed. note: peterfalkenbergbrown last edited this post 14 years, 9 months ago.]
      Visit The Significato Journal ~ nectar for the soul ~ http://significatojournal.com