.htaccess redirection - a tricky one (... or maybe not)
.htaccess redirection - a tricky one (... or maybe not)
am 14.06.2007 21:30:51 von henri
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
Re: .htaccess redirection - a tricky one (... or maybe not)
am 15.06.2007 01:23:45 von shimmyshack
On Jun 14, 8:30 pm, Henri 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
Re: .htaccess redirection - a tricky one (... or maybe not)
am 15.06.2007 11:33:37 von henri
shimmyshack wrote:
> On Jun 14, 8:30 pm, Henri 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
>
>
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...
Re: .htaccess redirection - a tricky one (... or maybe not)
am 15.06.2007 18:03:49 von shimmyshack
On Jun 15, 10:33 am, Henri wrote:
> shimmyshack wrote:
> > On Jun 14, 8:30 pm, Henri 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/andof 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
>
> 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/
Re: .htaccess redirection - a tricky one (... or maybe not)
am 15.06.2007 18:09:28 von shimmyshack
On Jun 15, 10:33 am, Henri wrote:
> shimmyshack wrote:
> > On Jun 14, 8:30 pm, Henri 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/andof 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
>
> 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
Re: .htaccess redirection - a tricky one (... or maybe not)
am 15.06.2007 19:59:23 von henri
shimmyshack wrote:
> On Jun 15, 10:33 am, Henri wrote:
>> shimmyshack wrote:
>>> On Jun 14, 8:30 pm, Henri 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/andof 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
>> 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?
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!