Last active
December 28, 2020 09:53
-
-
Save shibbirweb/147ee1a13529b3b8acbd44e0e42ca570 to your computer and use it in GitHub Desktop.
Redirect non-www to www & http to https .htaccess scripts
This file contains 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
RewriteEngine On | |
#redirect non-www to www for all domain | |
RewriteCond %{HTTP_HOST} !^www\. | |
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] | |
#redirect non-www to www for specific domain | |
RewriteCond %{HTTP_HOST} ^example\.com | |
RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L] | |
#redirect http to https | |
RewriteCond %{HTTPS} off | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment