I am trying to use PHP mod_rewrite to alter some URLs.
As a test, in my .htaccess I have the following:
RewriteEngine on
RewriteRule ^(.*[^/])$ index.php?test=$1
#RewriteRule ^([^/]+)/$ index.php?test=$1
In my index.php file I have simply
<?php print_r($_GET) ?>
What I would like to happen is that when either mysite.com/test or mysite.com/test/ is in the browser address bar, the PHP $_GET[‘test’] variable has the value ‘test’ in it.
The commented line works fine with mysite.com/test/ but seems to do nothing with mysite.com/test
The second line (the uncommented one) results in a value of ‘index.php’ for $_GET[‘test’] when viewing mysite.com/test and doesn’t do anything with mysite.com/test/
Is there anything I’m overlooking here that will allow me to get the desired results?
Thanks
Try this:
Note for
*?quantifier, which declares*to beungreedyhttp://www.troubleshooters.com/codecorn/littperl/perlreg.htm#Greedy