Forum Moderators: phranque
www.domain1.com
www.domain2.co.za (parked)
www.domain3.co.za (parked)
The site is split into two (eg. one for guys, one for girls)
www.domain1.com/home.php = site 1
www.domain1.com/site2/ = site2
I want if ppl go to www.domain2.co.za to go to www.domain2.co.za/site2/
and if people go to www.domain1.com to go to www.domain1.com/home.php
So far I've done some htaccess for preventing duplicate content:
RewriteCond %{HTTP_HOST} ^domain2.co.za [nc]
RewriteRule (.*) http://www.domain2.co.za/$1 [R=301,L]
#####
RewriteCond %{HTTP_HOST} ^domain1.com [nc]
RewriteRule (.*) http://www.domain1.com/$1 [R=301,L]
#####
RewriteCond %{HTTP_HOST} ^domain3.co.za [nc]
RewriteRule (.*) http://www.domain1.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.domain3.co.za [nc]
RewriteRule (.*) http://www.domain1.com/$1 [R=301,L]
Thanks in advance!
[edited by: jatar_k at 1:25 pm (utc) on Oct. 17, 2007]
[edit reason] delinked [/edit]
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim
Currently you go to domain1.com/ its a splash page:
> Click here to go to site 1 (/home.php)
> Click here to go to site 2 (/site2/)
The domain has 2 parked domains
site1.com being the parent
site1.co.za meant to take people to the same place
and now site2.co.za which i want to take people to /site2/
Should this just work for the root, or does it need to be site-wide?Which URL do you want the user to see in their browser?
It must be site-wide and there will be two possible urls showing:
site1.com (not .co.za as the .com is more established in search engines) and now also site2.co.za
Hope this makes more sense?
Main priority is to first get site2.co.za to go to site2.co.za/site2/
After I can get that right i'd like to try get site1.co.za/ and site1.com to go to site1.com/home.php
Thanks
[edited by: BooGiE_MaN at 11:14 pm (utc) on Oct. 17, 2007]
A RewriteRule can have as many RewriteConds as you like.
An else clause is implemented by ending the rule with an [L] flag. If the rule executes, then nothing after it will be executed. If the RewriteConds or RewriteRule conditions are not met, then that rule will not execute, the [L] flag will not stop rule processing, and the following rule will be evaluated, thus yielding the "Else" construct.
There are some limits and constraints on the boolean combinations you can construct using the default AND between RewriteConds, the optional [OR] specified with a flag on the RewriteCond(s), the "¦" local OR inside regular-expressions patterns, and the "[^]" character-group-negation and "!" pattern-negation operators, but generally, any function you can explain in concise comments can be implemented -- Or can be further broken down so that it can implemented.
Jim
Do not mix-up the 'parts' of the URL; The HTTP_HOST variable contains only the 'domain' and an optional appended port number, while REQUEST_URI contains only the local URL-path. REQUEST_URI does not include the domain or any query string data appended to the requested URL-path.
Something like this is probably what you're looking for:
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.co\.za
RewriteCond %{REQUEST_URI} !^/site2
RewriteRule (.*) http://www.domain1.co.za/site2/$1 [R=301,L]
Jim