1

I'm having issues forcing an SSL on my website. I think the issue may be that my root folder is my 'web' folder.

I've searched online and tried a few variations of htaccess but none of them seem to work.

Here is the latest I've tried:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # Send would-be 404 requests to Craft
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
    RewriteRule (.+) index.php?p=$1 [QSA,L]
</IfModule>

My domain points to my web folder and my htaccess belongs in the web folder.

Thanks,

Joe

1

For better practice, you should never use ".htaccess" file. Especially your problem can be easily solved by modify Apache configure file.

You should be able to find an Apache configure file somewhere in your /etc folder. On my server its /etc/httpd/conf/httpd.conf.

Then just find the code

<VirtualHost *:80>
   ... your server setting
   ServerName your-server-address.com
   # add the following line
   Redirect permanent / https://your-server-address.com/
</VirtualHost>

Don't forget to restart your server after you done the change. This will redirect any traffic trying to visit your site with none ssl to ssl, regardless your folder structure.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.