mod_rewrite fun

Caporegime
Joined
16 May 2003
Posts
25,367
Location
::1
I'm trying to use a mod_rewrite to turn out a URL in the form /test/12, which gets rewritten to test.php?id=12, using

Code:
RewriteRule test/([0-9]+)/$ test.php?id=$1

For now, test.php just contains

PHP:
<?php
print_r($_SERVER['argv']);
?>

The idea being the expected output from the page is
Array ( [0] => id=12 )

Except I don't get that, I just get Array ( ) - ie the ?id=$1 is getting chucked away. The result's exactly the same if I empty the .htaccess and disable mod_rewrite, so it would seem unlikely that mod_rewrite is the cause, but some Apache thing that's seeing the "test", and running off to test.php.

If I change the first "test" to "blahdeblah" in the RewriteRule, and change the URL to /bladeblah/12, everything works as expected.

Any suggestions to fix this, or is it something I have to work around?
 
Last edited:
Just tried it on another server (test folder on the production setup), and it worked - except it's running Apache 1.3.34, and I'm running (as above) 2.0.55 - so it's looking like an Apache 2 "feature"?
 
Got it - with a little help from the Apache users mailing list.

For reference, stick Options -MultiViews into the .htaccess, and everything works. :D
 
Back
Top Bottom