ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Force https:// with htaccess?

October 03, 2012 5:42am

Subscribe [2]
  • #1 / Oct 03, 2012 5:42am

    Visualis

    23 posts

    Hi there!

    I am up and running an expressionengine site with SSL for the first time. General configurations and all other settings are set to use https:// Working fine except this one thing:
    I want to force https:// for everyone who enters a url with http://

    This is what my htaccess looks like now - it’s removes index.php from url’s.

    <IfModule mod_rewrite.c>
            RewriteEngine On
    
            # Removes index.php
            RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ /index.php/$1 [L]
    
            # If 404s, "No Input File" or every URL returns the same thing
            # make it /index.php?/$1 above (add the question mark)
    </IfModule>

    Do you know how to do that? I’m no .htaccess-rewrite-wizzard 😊

  • #2 / Oct 04, 2012 4:17pm

    Dan Decker

    7338 posts

    Hi Visualis,

    Add this to your .htaccess

    <IfModule mod_rewrite.c>
            RewriteEngine On
    
    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*)$ <a href="https://www.example.com/$1">https://www.example.com/$1</a> [R,L]
    
            # Removes index.php
            RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ /index.php/$1 [L]
    
            # If 404s, "No Input File" or every URL returns the same thing
            # make it /index.php?/$1 above (add the question mark)
    </IfModule>

    That will send all incoming traffic on port 80 to rewrite to https

    Cheers!

  • #3 / Oct 08, 2012 4:21am

    Visualis

    23 posts

    Thank you, Dan! Works just as I wanted it to.

    Cheers!

  • #4 / Oct 09, 2012 10:55am

    Shane Eckert

    7174 posts

    Hey Visualis,

    I am really glad that Dan was able to help!

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases