Apache Server configuration support - Redirect all traffic except one specific directory?

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > June 2007 > Redirect all traffic except one specific directory?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Redirect all traffic except one specific directory?
Bernie Bernbaum

2007-06-23, 7:21 pm

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?
HansH

2007-06-23, 7:21 pm

"Bernie Bernbaum" <somebody@somedomain.not> 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


Bernie Bernbaum

2007-06-23, 7:21 pm

"HansH" <hansh@invalid.invalid> wrote in message
news:467d8913$0$331$e4fe514c@news.xs4all.nl...
> "Bernie Bernbaum" <somebody@somedomain.not> schreef in bericht
> news:tN-dnTdS0s01GeDbnZ2dnUVZ_gidnZ2d@comcast.com...
> Thus, the two intentionally do not have matching file trees?
>
>
> 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



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com