[users@httpd] mod_rewrite with [last] not behaving as expected

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

 



Hi All

I've been trying to set up some rewriting rules with mod_rewrite, and discovered that even with a [last] directive, things aren't quite behaving as I'd expect.

My config is perhaps slightly unusual, in that I have a default rule that applies, at the bottom of the rewrite block. The config is something like:

DocumentRoot /var/www/foo/
<Directory /var/www/foo/>
	RewriteEngine on
	RewriteRule ^foo/foo.xsd /schema/foo.xsd [last]
	RewriteRule ^foo/.* /schema/about_foo.html [last]
	RewriteRule .* http://somewhere-else/ [R]
</Directory>

Turning on RewriteLog and RewriteLogLevel, I see that a request for /foo/bar is re-written as an internal redirect to /schema/about_foo.html. No further rewriting occurs. The problem is that apache decides that it then needs to start processing /schema/about_foo.html from the top of my rewriting block, since it too falls within the Directory. It then runs off, does more rewriting, and goes to the wrong place.

In short, the [last] directive stops this re-writing run, but doesn't prevent further runs.

Is this behaviour:
a) expected (except by me!) or unexpected?
b) if expected, should we add another mod_rewrite flag to prevent further
    mod_rewrites touching the request? (eg [nofurther])

(For anyone suffering the same issue, my workaround was to add a <Directory> for the schema subdir, with RewriteEngine on, but no rules)

Nick

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