Generic HTACCESS Forces SSL & Non-WWW

Article 141 in HTACCESS

2021-08-01 07:59:02 from bugfish
Generic HTACCESS Forces SSL & Non-WWW
Last Review on: 2022-05-23 11:04:16 | Hits: 289

This is the code for an .htaccess file which does:

-> Redirect all www requests to non-www requests
-> Always force SSL

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

I do not guarantee the reliability of the information given here, the code described on this page is executed at your own risk and in the event of damage or other unforeseeable consequences I am in no way responsible or liable.
Currently 0 Upvotes!
captcha image
System - 2021-08-01 07:59:06
We appreciate comments on our site!
Switch: 100 | Arrive: 163
This Website is using Session Cookies for Site Functionality and AWStats.