Last active
February 13, 2024 20:37
-
-
Save AndrewChamp/3e4035341c2a3e8b8e1c75d7420fc0c3 to your computer and use it in GitHub Desktop.
Force Port 80 or Port 443 via .htaccess. This will also remove www. from the url.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# FORCE PORT 80 (insecure / regular traffic) | |
RewriteEngine On | |
RewriteCond %{HTTPS} on | |
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
########################################################### | |
#FORCE PORT 443 && REMOVE WWW. (secure / SSL) | |
RewriteCond %{SERVER_PORT} 80 | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L] | |
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] | |
RewriteRule ^(.*)$ https://%1/$1 [R=301,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment