Re: [users@httpd] unexpected RewriteRule behavior

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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

Well, yes, that is what I was asking.

> Do not change anything with "picts" in it.

You might try prefacing the entire thing with

RewriteRule picts - [L]

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

That might be:

RewriteRule ^/$ /index.cgi [PT,QSA]
RewriteRule ^/.+/$ /index.cgi [PT,QSA]

> 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.

There's one problem with this approach. The arguments following a ? are
not part of what you are allowed to consider in a RewriteRule. That is,
RewriteRule considers the REQUEST_URI, not including the http:// or the
hostname or the QUERY_STRING (the QUERY_STRING is the bit starting with
the ?). If you want to retain the QUERY_STRING, you need to use the QSA
flag (QUERY STRING APPEND) to do that. Granted, there's a chance that it
appeared to be working anyway, because of the trailing ? making the
whole thing optional.

> 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.

Well, understanding why you want to do it *might* suggest alternate
approaches, but, then again, it might not. Hard to know a priori.

As Joshua said, one of your best tools at this point is the RewriteLog,
since it tells you exactly what mod_rewrite thinks is going on. That is
sometimes enough to figure out why a particular rule isn't doing what
you expect it to do. I also find Regex Coach or ReBug to be a great tool
to find out no only what matched, but why it matched and which parts
were assigned to $1 and so on.

- --
Rich Bowen
rbowen@xxxxxxxxxxx
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDaKObXP03+sx4yJMRAoWPAJ4s2TjK+XEuQzn2ZYoM68bD7hqE3gCg3FxN
7cm8y8G3zgkfQSp+hCqVMzs=
=V5+o
-----END PGP SIGNATURE-----

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