views:

93

answers:

2

I'm trying to debug URL rewriting on a hosted site, where I don't have access to vhost.conf and so can't set up a rewrite log. How else can I debug rules that aren't working?

This is the rule I'm trying to straighten out, if anyone has any insight:

RewriteRule ^([^/]+)\.([^/]+)$ xslt.php [L]

What I expect to have happen: URLs that have dots but no slashes to be rewritten to point to xslt.php and then stop rewriting, so that it doesn't go into a loop. What actually happens? 500 Internal Server Error (which smells like it is looping). I know I can add a RewriteCond to specifically exclude xslt.php, but I'd prefer to understand why this is breaking first.

+3  A: 

Why wouldn't it loop? xslt.php has dots but no slashes. Try changing your options to [L,NS].

Edit: Ah, I see. What you're missing is that [L] terminates all rewriting for this request, but a subrequest is still generated that gets its own rewrite pass. [NS] suppresses that pass.

chaos
And here I though my mod_rewrite-fu was pretty good. ;-)
Ben Blank
Probably is. It's deep enough magic that there's a lot of territory left past "pretty good". :)
chaos
A: 

The L flag causes a restart of the rewrite process using the new, rewritten URL xslt.php that then is also matched by your pattern.

So try this:

RewriteCond $0 !^xslt\.php$
RewriteRule ^([^/]+)\.([^/]+)$ xslt.php [L]
Gumbo