RE: [users@httpd] unexpected RewriteRule behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Rich Bowen [mailto:rbowen@xxxxxxxxxxx] 
> Sent: Tuesday, November 01, 2005 7:24 PM
> To: users@xxxxxxxxxxxxxxxx
> Subject: Re: [users@httpd] unexpected RewriteRule behavior
> 
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Michael D. Berger wrote:
> > [...]
> > 
> >>From: Rich Bowen [mailto:rbowen@xxxxxxxxxxx] 
> > 
> > [...]
> > 
> >>Michael D. Berger wrote:
> >>
> >>>The following:
> >>
> >>>   RewriteCond %{REQUEST_URI} !^.*/picts/.*$
> >>>   RewriteRule ^/(.*/)?$ /index.cgi [L]
> 
> ...
> 
> > The picts line is functioning as expected.  Such lines are
> > handled differently elsewhere. With regard to the RewriteRule
> > line, this is functioning correctly only of you ignore the
> > '$' end-of-line anchor.  From a linux box:
> > 
> >    echo // | grep -P "^/(.*/)?$"
> >    //
> >    echo / | grep -P "^/(.*/)?$"
> >    /
> >    echo /x.y | grep -P "^/(.*/)?$"
> 
> That's correct. It doesn't match, because the (.*/) is optional, and
> when it's *not* there, then the regex is equivalent to ^/$ - ie, it
> insists that it ends with the slash, which this string does not do.
> 
> >    echo /x.y/ | grep -P "^/(.*/)?$"
> >    /x.y/
> > 
> > Notice the one line that doesn't echo.  BTW, this is exactly
> > what I am trying to do.  The question is why the difference
> > between grep -P and RewriteRule?  I have yet to follow the
> > advice in another response and turn on logging.
> 
> I'm sorry, it's still not clear what you're trying to accomplish with
> these rules. Can you state in words what the rules are 
> supposed to solve?
> 
> - --
> Rich Bowen
> rbowen@xxxxxxxxxxx

What the rules are "supposed to solve" is not relevant to this
discussion. This is what they are >supposed to do<.

Do not change anything with "picts" in it.

For the rule above:
Change to /index.cgi for:
   /
   anything that both begins and ends in "/", i.e. "/.*/"

The other rule, not shown here, was incorrect.  The corrected version is:
   RewriteRule ^/.*\.html(\?.*$)? /index.cgi$1 [L]

This will call /index.cgi for any URL that begins in "/", ends in ".html",
and optionally has argumenmts following a ?.  If there are arguments,
they will be passed to index.cgi.

Perhaps there is difficulty because it is not obvious why I would want
to do this.  Suffice it to say that index.cgi is rather complex.

Mike.
--
Michael D. Berger
m.d.berger@xxxxxxxx 

[...]



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux