Force HTTPS request using .htaccess

I have an image folder that only HTTPS should be accessible to. How to redirect all requests from HTTP to HTTPS?

+3
source share
2 answers
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

That should do it.

+4
source
RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

The search keyword is the next time you want to learn how to redirect something: mod_rewrite

+1
source

Source: https://habr.com/ru/post/1779492/


All Articles