Forum Moderators: phranque
Ive got a domain that i just want to use for testing purposes. So i want to redirect everything except dev.newdomain.co.uk to www.otherdomain.com
How can this be done? Ive tried this:
RewriteCond %{HTTP_HOST} ^newdomain\.co\.uk [NC]
RewriteCond %{HTTP_HOST} !^dev\.newdomain\.co\.uk [NC]
RewriteRule (.*) [otherdomain.com...] [R=301,L,NC]
But to be honest, i dont know what it actually says.
Cheers for any help
As an example, by using a 301 redirect, you're telling the search engines that this is a permanent move. If you ever intend to put "newdomain.co.uk" on-line, you may have cost yourself up to a year of bad search rankings by telling the search engines that newdomain.co.uk has been moved permanently to otherdoman.com. A 302 would likely be much more appropriate.
Also, because the first two RewriteConds are logically incorrect, only "newdomain.co.uk" will be redirected, and the second RewriteCond really won't do anything since it will always evaluate as 'true' when the first RewriteCond is true. If the requested hostname is not exactly "newdomain.co.uk", then the first RewriteCond will evaluate as false, the second will therefore be irrelevant, and the rule won't be invoked.
So the code won't work as you wish due to this internal inconsistency. Unfortunately, you did not describe the significance of all three domain references, so I can't offer any advice on how to fix it.
Jim