|
Home > Archive > Apache Server configuration support > June 2007 > .htaccess redirection - a tricky one (... or maybe not)
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 |
.htaccess redirection - a tricky one (... or maybe not)
|
|
|
| Hi,
I have a peronal site at my.name.ips.fr and an other at www.mydomain.com
and I've put an .htaccess permanent redirection at the root of the former:
Redirect permanent / http://www.mydomain.com/
and it does its job like it's supposed to... BUT I'd like to keep some
of the contents of the first site accessible, like, for instance,
my.name.ips.fr/foo/
Because of the redirection, a request for my.name.ips.fr/foo/ is
directed to www.mydomain.com/foo/ and of course there's no /foo/ there.
And I don't want to transfer foo/ because it does not belong into
www.mydomain.com
So, my objective is
permanently redirect all request for the root directory (of
my.name.ips.fr) and for most of its siblings but do not redirect
requests to other selected siblings (eg foo). See what I mean?
Sort of like a conditional redirect.
I can put on a series of Redirects, one for each file or directory, but
I wonder if there exist some smarter way of doing this (with a regular
expresssion)
Redirect permanent ^(/*^/foo)$ http://www.mydomain.com/
(redirect everything but requests for foo/)
Anybody in a helping mood?
Lazyeye
| |
| shimmyshack 2007-06-14, 7:25 pm |
| On Jun 14, 8:30 pm, Henri <yeah_ri...@donteventry.com> wrote:
> Hi,
>
> I have a peronal site at my.name.ips.fr and an other atwww.mydomain.com
> and I've put an .htaccess permanent redirection at the root of the former:
>
> Redirect permanent /http://www.mydomain.com/
>
> and it does its job like it's supposed to... BUT I'd like to keep some
> of the contents of the first site accessible, like, for instance,
> my.name.ips.fr/foo/
>
> Because of the redirection, a request for my.name.ips.fr/foo/ is
> directed towww.mydomain.com/foo/and of course there's no /foo/ there.
> And I don't want to transfer foo/ because it does not belong intowww.mydomain.com
>
> So, my objective is
>
> permanently redirect all request for the root directory (of
> my.name.ips.fr) and for most of its siblings but do not redirect
> requests to other selected siblings (eg foo). See what I mean?
>
> Sort of like a conditional redirect.
>
> I can put on a series of Redirects, one for each file or directory, but
> I wonder if there exist some smarter way of doing this (with a regular
> expresssion)
>
> Redirect permanent ^(/*^/foo)$http://www.mydomain.com/
provding they are directories you can add a trailing slash to prevent
a further redirection, the 301 is the permanent redirection, this rule
obviously redirects
/foo
/another
/a_third/something
and
/foo/
/another/
/a_third/something/
RedirectMatch 301 /?(foo|another|a_third/something)/?$ http://www.mydomain.com/$1/
>
> (redirect everything but requests for foo/)
>
> Anybody in a helping mood?
>
> Lazyeye
| |
|
| shimmyshack wrote:
> On Jun 14, 8:30 pm, Henri <yeah_ri...@donteventry.com> wrote:
>
> provding they are directories you can add a trailing slash to prevent
> a further redirection, the 301 is the permanent redirection, this rule
> obviously redirects
> /foo
> /another
> /a_third/something
> and
> /foo/
> /another/
> /a_third/something/
>
>
> RedirectMatch 301 /?(foo|another|a_third/something)/?$ http://www.mydomain.com/$1/
>
>
>
ok, thanks.
This rule redirects requests to foo, another, or a_third/something
however, I'm seeking exactly the contrary: requests to foo or another or
a_third are not to be redirected; evething else is.
So what i'm looking for is a regexp that means
NOT(foo|another|a_third/something)/?
I wonder if something like [^(foo|another|a_third/something)] would do
the trick...
| |
| shimmyshack 2007-06-15, 1:23 pm |
| On Jun 15, 10:33 am, Henri <yeah_ri...@donteventry.com> wrote:
> shimmyshack wrote:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ok, thanks.
>
> This rule redirects requests to foo, another, or a_third/something
> however, I'm seeking exactly the contrary: requests to foo or another or
> a_third are not to be redirected; evething else is.
>
> So what i'm looking for is a regexp that means
>
> NOT(foo|another|a_third/something)/?
>
> I wonder if something like [^(foo|another|a_third/something)] would do
> the trick...
yeah use ! at the front, sorry you could probably use (untested) this,
might even be poss to use just one ! at front, but I dont think that
would work - havent time to test it
RedirectMatch 301 /?(!foo|!another|!a_third/something)/?$http://
www.mydomain.com/$1/
| |
| shimmyshack 2007-06-15, 1:23 pm |
| On Jun 15, 10:33 am, Henri <yeah_ri...@donteventry.com> wrote:
> shimmyshack wrote:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ok, thanks.
>
> This rule redirects requests to foo, another, or a_third/something
> however, I'm seeking exactly the contrary: requests to foo or another or
> a_third are not to be redirected; evething else is.
>
> So what i'm looking for is a regexp that means
>
> NOT(foo|another|a_third/something)/?
>
> I wonder if something like [^(foo|another|a_third/something)] would do
> the trick...
actually that last post /?(!this|!that|!etc)/ ...
by me was just bs, man I have to stop posting before thinking. sorry
the way I would do it is using a rewritecond and using rewrites do you
have rewrites on?
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
ReWriteRule /?(^/)$ http://www.mydomain.com/$1/
because any content NOT on the server would then be handled by the
second server.
sorry to be so confused and confusing
| |
|
| shimmyshack wrote:
> On Jun 15, 10:33 am, Henri <yeah_ri...@donteventry.com> wrote:
>
> actually that last post /?(!this|!that|!etc)/ ...
> by me was just bs, man I have to stop posting before thinking.sorry
> the way I would do it is using a rewritecond and using rewrites do you
> have rewrites on?
Don't be sorry. I usually do the posting before the cogitating!
The first server is that of an isp, with no extra modules loaded, so I
can forget about rewrite rules. I can put up a php page and some code
doing the url-analyzing and redirecting but that wouldn't be as clean as
using an .htaccess redirectmatch.
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> ReWriteRule /?(^/)$ http://www.mydomain.com/$1/
>
> because any content NOT on the server would then be handled by the
> second server.
>
> sorry to be so confused and confusing
>
Well, don't worry about that. But thanks anyway for the effort.
I have to study regexps some more, maybe I'll come up /w something
Sheers!
|
|
|
|
|