Forum Moderators: phranque

Message Too Old, No Replies

redirect from .com to .co.uk, but exclude some directories

redirect from .com to .co.uk excluding dirs

         

renton84uk

4:50 pm on Nov 23, 2010 (gmt 0)

10+ Year Member



Hi,

I would like to do the following but just cant work out it.

I have domain.com and domain.co.uk

domain.com is the main site, and domain.co.uk hosts images which load in domain.com

I want domain.co.uk to point to domain.com if anyone vist, but this is redirecting all requests to .co.uk to .com. So all the images in .com are being redirect from .co.uk to .com.

images are in subdirectories of domain.co.uk/components and domain.co.uk/images

So i tried this and many variasions, but it just keep redirecting everything.

#if requesting access to domain.co.uk root
RewriteCond %{HTTP_HOST} .domain\.co\.uk$ [NC]
#and not requesting access to componets or image directory or their subdirectories
RewriteCond %{HTTP_HOST} !.domain\.co\.uk/(components|images/.*)
#redirect to .com
RewriteRule (.*)$ [domain.com...] [R=301,L]

Can anyone please help me to get this working?

thanks

renton84uk

5:20 pm on Nov 23, 2010 (gmt 0)

10+ Year Member



i did it like this

RewriteCond %{HTTP_HOST} domain\.co\.uk$ [NC]
RewriteCond $1 !^(components|images|templates|media|module)
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

[edited by: jdMorgan at 9:57 pm (utc) on Nov 30, 2010]
[edit reason] de-linked target URL for clarity [/edit]