Forum Moderators: phranque

Message Too Old, No Replies

Redirect entire site, except subdomain?

         

Major Disaster

1:45 am on Nov 2, 2009 (gmt 0)

10+ Year Member



Hey,

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

jdMorgan

5:38 pm on Nov 2, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Don't use any code that you don't understand, as the technical term for this practice often translates as "suicide." Please spend some time with the relevant documentation cited in our Apache Forum Charter, and take your code apart -- character-by-character if necessary, until you understand it completely. Otherwise, you'd be better off developing on an unroutable PC LAN address instead of using a publicly-accessible domain.

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