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

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

<p>Then just find the code </p>

<pre><code>&lt;VirtualHost *:80&gt;
   ... your server setting
   ServerName your-server-address.com
   # add the following line
   Redirect permanent / https://your-server-address.com/
&lt;/VirtualHost&gt;
</code></pre>

<p>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.</p>

CC BY-SA 4.0
2019-08-15T00:55:44.203Z
2019-08-16T01:22:59.320Z
2019-08-16T01:22:59.320Z
Parry Huang
<p>I'm having issues forcing an SSL on my website. I think the issue may be that my root folder is my 'web' folder.</p>

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

<p>Here is the latest I've tried:</p>

<pre><code>&lt;IfModule mod_rewrite.c&gt;
    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]
&lt;/IfModule&gt;
</code></pre>

<p>My domain points to my web folder and my htaccess belongs in the web folder.</p>

<p>Thanks,</p>

<p>Joe</p>

<craft3><ssl>
Force SSL on sub folder
# Force SSL on sub folder

(Asked by: username_0 on 2019-08-14)

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:

    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]


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

**Tags:** craft3, ssl

---

## 1 answers

### Answer by username_1 on 2019-08-15. Score: 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 

   ... your server setting
   ServerName your-server-address.com
   # add the following line
   Redirect permanent / https://your-server-address.com/


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.


---

