Last active
February 13, 2025 17:49
-
-
Save tecpromotion/867caccbd2ec6c7d2a5d682055b5e43e to your computer and use it in GitHub Desktop.
.htaccess-www-to-non-www #htaccess
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
| RewriteEngine On | |
| RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC] | |
| RewriteRule ^(.*)$ https://yourdomain.com/$1 [L,R=301] |
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
| RewriteEngine On | |
| # Redirect non-www to www | |
| RewriteCond %{HTTP_HOST} ^yourdomain\.com [NC] | |
| RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [L,R=301] | |
| # Force HTTPS (if not already HTTPS) | |
| RewriteCond %{HTTPS} !=on | |
| RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] |
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
| RewriteEngine On | |
| # Redirect www to non-www (force non-www) | |
| RewriteCond %{HTTP_HOST} ^www\.(yourdomain\.com) [NC] | |
| RewriteRule ^(.*)$ https://%1/$1 [L,R=301] | |
| # Force HTTPS (if not already HTTPS) | |
| RewriteCond %{HTTPS} !=on | |
| 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