If rewrites worked the way you are thinking, the above would be saying:
- if the user asks for b.com
- then rewite the url for a.co.uk to another address on a.co.uk.
This is like saying "If someone is driving down Hwy 5, create an offramp on Hwy 95 to detour them to go the other direction on Hwy 95". Since the driver on Hwy 5 isn't on Hwy 95, he's never going to see the offramp.
But actually, rewrites don't work the way you are thinking. The reason you need to test for the HTTP_HOST in the condition is because that is NOT available in the RewriteRule. So the domain in the match would have to be in the request for any match to ever occur. The replacement might (in a 301 redirect).
To actually answer your question, you still need to answer g1smd's original questions. What seems clear to you is in fact rather vague and you're not getting precise answers because you are not asking precise questions.
1. What does the original URL look like? Give three examples such as
www.b.com/folder/page1
www.b.com/folder2/page1
As it stands from what you've said so far, you want to rewrite every request to b.com to the same page.
2. What URL do you want to show in the browser address bar for each one of these addresses?
www.b.com/folder/page1 -> a.co.uk/?
www.b.com/folder2/page1 -> a.co.uk/?
www.c.com/folder1/page1 -> a.co.uk/?
You say you want THISPAGE1 - will you just manually create a rewrite for every domain (which is fine) since there's no pattern here (i.e. no matching characters aside from the shared 1)
3. Where are the actual files you want these to point to? Based on what you have given us I assume this is custom in every case, but with only one example it's impossible to know what you're really asking
a.co.uk/THISPAGE1 --> a.co.uk/folder1/page1
So where do the following point?
a.co.uk/THISPAGE2
a.co.uk/folder/THISPAGE1
So with those questions still left out there, I expect what you want is something like this (note using https so the forum software doesn't change it into a live link).
RewriteCond %{HTTP_HOST} ^(www\.)?b\.com$ [NC]
RewriteRule .* [
a.co.uk...] [R=301]
RewriteRule ^THISPAGE1$ folder1/page1 [L]
This basically says
- if the request URL is b.com with/without www and with/without a path beyond the domain
- then redirect to [
a.co.uk...]
- and throw away anything in the request path aside from the domain
- but point that address to another place on the file system, namely at a.co.uk/folder1/page1 (using a path relative to the present location of the .htaccess file, which may or may not be correct).
But that makes many assumptions about what you want.