Re: [Nolug] Off topic, Apache 2.x question

From: Jesse Planck <jesse.planck_at_gmail.com>
Date: Thu, 25 Aug 2005 12:42:27 -0500
Message-ID: <c141e08605082510425af4b6d1@mail.gmail.com>

Mod_Rewrite burns brain cells.

It's actually an issue of redirecting to a location that just keeps on
redirecting which creates a potentially hazardous loop.

The solution is to exclude the DocumentIndex file and the single "/"
for entry using RewriteCon. Just remember if your DocumentIndex is
different from index.html or if you have more that one you will have
to add RewriteCond(s).

    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^/index.html$
    RewriteCond %{REQUEST_URI} !^/$
    RewriteRule ^/(.*) http://www.domain.com/ [R]

Each RewriteCond acts as an or statement. The %{REQUEST_URI} pulls the
"Get" from the http header. Notice the "!" in front of the "^" of
couse that means "not". As usually the "^" is the start and the "$" is
the end... I always forget the flippin "$"

Once the request passes the mustard of RewriteCond it moves to the
RewriteRule. There we say match everything and redirect to that
domain... do a force redirect with [R]....

Tada!

I think that covers it.

Jess

On 8/25/05, Brett D. Estrade <estrabd@mailcan.com> wrote:
> If the directories do not exist, why not just set up a 404 page that is
> actually your main index?
>
> Brett
>
>
> On Wed, 24 Aug 2005 14:57:51 -0500 (CDT), "David John"
> <david@digitalsolutions-la.com> said:
> > Hello All,
> >
> > Scenario:
> > Given the domain example.com. A user requests any subdirectory on
> > example.com, say example.com/anydirectory. I would like to rewrite or
> > redirect all requests from example.com/anydirectory back to the
> > DocumentRoot of example.com. Essentially, I want to create a one page
> > domain that returns the user to the DocumentRoot of example.com
> > regardless
> > of what subdirectory they request. Does that make sense?
> >
> > Would I use mod_rewrite for this? If so, how? Using
> > http://httpd.apache.org/docs/2.0/misc/rewriteguide.html as a guide, I
> > tried using regular expressions but always get redirection limit exceeded
> > messages or nothing at all.
> > I'm using something like this for my VirtualHost in httpd.conf:
> >
> > RewriteEngine On
> > RewriteRule ^/~(([a-z])[a-z0-9]+)(.*) http://example.com
> >
> > (I know I'm probably way off.)
> >
> > I've Googled this one to death. Maybe I'm not searching for the right
> > stuff for what I'm trying to accomplish? Any help is appreciated.
> > Thanks.
> >
> > David John
> >
> > ___________________
> > Nolug mailing list
> > nolug@nolug.org
> --
>
> ~Sedit qui timuit ne non succederet~
>
> ___________________
> Nolug mailing list
> nolug@nolug.org
>

___________________
Nolug mailing list
nolug@nolug.org
Received on 08/25/05

This archive was generated by hypermail 2.2.0 : 12/19/08 EST