Created
March 4, 2015 19:39
-
-
Save sidisinsane/6d77b537e8c464710b37 to your computer and use it in GitHub Desktop.
placeholder redirects
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
######################################################################################## | |
# store requested protocol in %{ENV:protocol} (i always use this...) | |
######################################################################################## | |
RewriteCond %{HTTPS} =on | |
RewriteRule ^(.*)$ - [env=protocol:https] | |
RewriteCond %{HTTPS} !=on | |
RewriteRule ^(.*)$ - [env=protocol:http] | |
######################################################################################## | |
# placeholder redirects (exclude specific matching redirects!) | |
######################################################################################## | |
# 1) exclude specific paths matching beneath pattern | |
RewriteCond %{HTTP_HOST} !^(www.)?domain.tld/old/abc$ | |
RewriteCond %{HTTP_HOST} !^(www.)?domain.tld/old/xyz$ | |
# 2) apply placeholder redirects to matching and not excluded | |
RewriteCond %{HTTP_HOST} ^(www.)?domain.tld/old/([a-z]+)$ | |
RewriteRule ^(.*)$ %{ENV:protocol}://domain.tld/new/%2 [R=301,L] | |
# 3) apply specific redirects to paths excluded in 1) | |
RewriteCond %{HTTP_HOST} ^(www.)?domain.tld/old/abc$ | |
RewriteRule ^(.*)$ %{ENV:protocol}://domain.tld/new/beginning [R=301,L] | |
RewriteCond %{HTTP_HOST} ^(www.)?domain.tld/old/xyz$ | |
RewriteRule ^(.*)$ %{ENV:protocol}://domain.tld/new/end [R=301,L] | |
######################################################################################## | |
# internal placeholder redirects, removing everything after matched pattern | |
######################################################################################## | |
RedirectMatch 301 /old/([a-z]+)/(.*)/ /new/$1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment