Redirect all traffic except one specific directory?

Redirect all traffic except one specific directory?

am 23.06.2007 22:38:01 von Burma Jones

This is a multi-part message in MIME format.

------=_NextPart_000_0008_01C7B59B.B7FD5620
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I want to redirect *all* traffic to http://mysite.com to =
http://destination.com, except for one specific directory.

Here is my .htaccess file:

RewriteEngine on
RewriteCond $1 !^SomeDirectory
RewriteRule (.*) http://destination.com/$1 [L]

So if I type in http://mysite.com/SomeDirectory it works fine, taking me =
to that directory. And if I type in http://mysite.com it takes me to =
http://destination.com.

But if I type in *anything* else, whether it is an actual directory or =
file, or whether it is a typo, it takes me to an error page on the =
destination site. For example, http://mysite.com/TypoError takes me to =
http://destination.com/TypoError with a "404 File Not Found Error".

Is there a way to have it so *anything* other than =
http://mysite.com/SomeDirectory will get redirected to =
http://destination.com?
------=_NextPart_000_0008_01C7B59B.B7FD5620
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable



charset=3Diso-8859-1">





I want to redirect *all* =
traffic to href=3D"http://mysite.com">http://mysite.com to href=3D"http://destination.com">http://destination.com, except for =
one=20
specific directory.

 

Here is my .htaccess =
file:

 


RewriteEngine on
RewriteCond =
$1=20
!^SomeDirectory
RewriteRule (.*) href=3D"http://destination.com/$1">http://destination.com/$1 =
[L]

 
size=3D2>

So if I type in href=3D"http://mysite.com/SomeDirectory">http://mysite.com/S omeDirectory<=
/A> it=20
works fine, taking me to that directory.  And if I type in href=3D"http://mysite.com">http://mysite.com it takes me to href=3D"http://destination.com">http://destination.com.

 

But if I type in *anything* =
else, whether=20
it is an actual directory or file, or whether it is a typo, it takes me =
to an=20
error page on the destination site.  For example, href=3D"http://mysite.com/TypoError">http://mysite.com/TypoE rror =
;takes me=20
to href=3D"http://destination.com/TypoError">http://destination .com/TypoErro=
r=20
with a "404 File Not Found Error".

 

Is there a way to have it so =
*anything*=20
other than href=3D"http://mysite.com/SomeDirectory">http://mysite.com/S omeDirectory<=
/A> will=20
get redirected to href=3D"http://destination.com">http://destination.com?
<=
/FONT>


------=_NextPart_000_0008_01C7B59B.B7FD5620--

Re: Redirect all traffic except one specific directory?

am 23.06.2007 22:58:50 von HansH

"Bernie Bernbaum" schreef in bericht
news:tN-dnTdS0s01GeDbnZ2dnUVZ_gidnZ2d@comcast.com...
> I want to redirect *all* traffic to http://mysite.com to
> http://destination.com, except for one specific directory.
> RewriteEngine on
> RewriteCond $1 !^SomeDirectory
> RewriteRule (.*) http://destination.com/$1 [L]
>
> But if I type in *anything* else, whether it is an actual directory
> or file, or whether it is a typo, it takes me to an error page on the
> destination site.
Thus, the two intentionally do not have matching file trees?

> For example, http://mysite.com/TypoError takes me to
> http://destination.com/TypoError with a "404 File Not Found Error".
>
> Is there a way to have it so *anything* other than
> http://mysite.com/SomeDirectory will get redirected to
> http://destination.com?

Do you really just want to redirect to the other site's root ??
RewriteRule (.*) http://destination.com/ [L]

HansH

Re: Redirect all traffic except one specific directory?

am 24.06.2007 00:11:34 von Burma Jones

"HansH" wrote in message
news:467d8913$0$331$e4fe514c@news.xs4all.nl...
> "Bernie Bernbaum" schreef in bericht
> news:tN-dnTdS0s01GeDbnZ2dnUVZ_gidnZ2d@comcast.com...
>> I want to redirect *all* traffic to http://mysite.com to
>> http://destination.com, except for one specific directory.
>> RewriteEngine on
>> RewriteCond $1 !^SomeDirectory
>> RewriteRule (.*) http://destination.com/$1 [L]
>>
>> But if I type in *anything* else, whether it is an actual directory
>> or file, or whether it is a typo, it takes me to an error page on the
>> destination site.
> Thus, the two intentionally do not have matching file trees?
>
>> For example, http://mysite.com/TypoError takes me to
>> http://destination.com/TypoError with a "404 File Not Found Error".
>>
>> Is there a way to have it so *anything* other than
>> http://mysite.com/SomeDirectory will get redirected to
>> http://destination.com?
>
> Do you really just want to redirect to the other site's root ??
> RewriteRule (.*) http://destination.com/ [L]

Dude, thanks! Yes that's what I want to do. So I just took off the '$1'
and bada bing it works!

> HansH