Last active
May 8, 2019 08:49
-
-
Save alrnz/a50e14286df4d0e86000 to your computer and use it in GitHub Desktop.
htaccess redirects for www and https #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
# redirect to german page | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{HTTPS} !=on | |
# domain matches | |
RewriteCond %{HTTP_HOST} ^www.domain\.de$ [NC] | |
# path is empty | |
RewriteCond %{REQUEST_URI} ^/$ | |
RewriteCond %{SERVER_ADDR} !=127.0.0.1 | |
RewriteCond %{SERVER_ADDR} !=::1 | |
RewriteRule ^(.*)$ http://www.domain.de/test/ [L,R=301] | |
</IfModule> | |
# redirect to www | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
# not https | |
RewriteCond %{HTTPS} !=on | |
# not www | |
RewriteCond %{HTTP_HOST} !^www\. [NC] | |
# domain matches (possible with \.de | |
RewriteCond %{HTTP_HOST} ^my-domain\. [NC] | |
RewriteCond %{SERVER_ADDR} !=127.0.0.1 | |
RewriteCond %{SERVER_ADDR} !=::1 | |
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment