Last active
November 8, 2022 12:34
-
-
Save developer-anuragsingh/23ca9ddb1eb4266126ca6b98a4f59323 to your computer and use it in GitHub Desktop.
301 redirect www to non-www & 301 Redirect HTTP to HTTPS
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
# BEGIN Redirects | |
RewriteEngine On | |
# 301 redirect www to non-www | |
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] | |
RewriteRule ^(.*)$ https://%1/$1 [R=301,L] | |
# 301 redirect non-www to www | |
RewriteCond %{HTTP_HOST} !^www\. | |
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
# 301 redirect to https | |
RewriteCond %{HTTPS} off | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
# END Redirects |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment