Administrators Nathan Posted February 16, 2018 Administrators Share Posted February 16, 2018 I know this is a pretty basic thing, but I've seen so many tutorials out there that are non-dynamic solutions. Normally when you google "How to force HTTPS using an .htaccess file" or "Redirect HTTP to HTTPS using an .htaccess file" you get examples like the below. RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.example.com/$1 [R,L] This does work, but you have to replace www.example.com with your domain and it's then hard-coded and not dynamic. I don't like hard-coding anything unless it's absolutely necessary, so here's an example of the dynamic way to redirect to https from http requests using your htaccess file. RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] View the Prodjex Blog post on How To Force HTTPS Using .Htaccess. WisTex 1 Quote Link to comment Share on other sites More sharing options...
Wilsonjacob45 Posted September 29, 2020 Share Posted September 29, 2020 Thanks for sharing the valuable answer according to https using htaccess. Nathan 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.