Created
January 7, 2015 01:26
-
-
Save l0neranger/65109af95daf9555ab98 to your computer and use it in GitHub Desktop.
Mod_Rewrite Example
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 | |
# | |
# If the request comes in on the domain cname, redirect to domain root | |
# | |
RewriteCond %{HTTP_HOST} ^www\.domain1\.com$ [NC] | |
RewriteCond %{HTTP_HOST} !^$ | |
RewriteRule ^/?(.*) http://domain1.com/$1 [L,R=301,NE,NC] | |
RewriteCond %{HTTP_HOST} ^www\.domain2\.com$ [NC] | |
RewriteCond %{HTTP_HOST} !^$ | |
RewriteRule ^/?(.*) http://domain2.com/$1 [L,R=301,NE,NC] | |
# | |
# Default Pages if the request comes in on the domain root with no appending url | |
# | |
RewriteCond %{HTTP_HOST} ^domain1\.com$ [NC] | |
RewriteCond %{REQUEST_URI} ^/?$ | |
RewriteRule ^/?$ http://domain1.com/url1 [L,R=301,NE,NC] | |
RewriteCond %{HTTP_HOST} ^domain2\.com$ [NC] | |
RewriteCond %{REQUEST_URI} ^/?$ | |
RewriteRule ^/?$ http://domain2.com/url2 [L,R=301,NE,NC] | |
# | |
# Legal Requirement wrt domain1 vs domain2 urls | |
# | |
RewriteCond %{HTTP_HOST} ^domain2\.com$ [NC] | |
RewriteCond %{REQUEST_URI} ^/url1$ [NC,OR] | |
RewriteCond %{REQUEST_URI} ^/url3$ [NC] | |
RewriteRule ^/?(.*) http://domain2.com/url2 [L,R=301,NE,NC] | |
RewriteCond %{HTTP_HOST} ^domain1\.com$ [NC] | |
RewriteCond %{REQUEST_URI} ^/url2$ [NC] | |
RewriteRule ^/?(.*) http://domain1.com/url1 [L,R=301,NE,NC] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
notes,self