Web Hosting Talk







View Full Version : htaccess redirect


adnbmusic
05-20-2004, 11:19 AM
I've been battling this one for ages now and have hunted high and low across a lot of forums for the answer - not even sure its possible.

Basically, I need visitors to be able to enter

://w3.domain1.com/folder/any_file_of_any_type
and be shown
://subdomain.domain2.com/any_file_of_any_type

but without the domain2 url being shown in the address bar.

I'm using shared hosting and there's no sign of a .htaccess file in my root directory - however, I can't risk putting the whole site out of action if I inadvertently overwrite the root .htaccess.

So, I've tried the following htaccess in the folder that I want to redirect:

RewriteEngine on
RedirectPermanent / ://subdomain.domain2.com/ [L]

Unfortuatenly, that only achieves redirecting as follows:

://w3.domain1.com/folder/any_file_of_any_type
to
://subdomain.domain2.com/folder/any_file_of_any_type

Any idea what's going wrong and how I can get around it? Any help very much appreciated

Thanks very much,

Ben
P.S. please ignore the odd urls - it won't let me post a fake one.

zupanm
05-20-2004, 11:25 AM
try this in the folder dir

RewriteEngine on
RewriteRule (.+) http://subdomain.domain2.com/$1 [R,L]

adnbmusic
05-20-2004, 11:40 AM
hi - thanks very much for the help.

i've just tried that - problem is its digging up all the folders above the folder that my shared hosting uses if you see what I mean and apending them onto the end of the subdomain.domain2.com so i'm getting subdomain.domain2.com/u/web/username/thefilename.

adnbmusic
05-20-2004, 11:42 AM
incidentally, could i use a subdomain on my domain name instead to redirect using CNAME in my zone record to the external subdomain? would that achieve hiding the real url?