fowardslahs problem

Topics: User Forum
Mar 9, 2007 at 5:25 PM
Hello,

If I visit visit the page http://www.chab-it.nl/temp/text/ then it works. But if i remove the forwardshlash at the end of the url, then it doesn't work.

I've got the following line in the ini-file: RewriteRule ^/temp/(^/+)/ /temp/test.php?string=$1

Can someone help me to get this problem fixed?
Mar 10, 2007 at 12:42 AM
Your rule is requiring the slash. If you want to make it optional, you should say somthing like:

RewriteRule ^/temp/(^\/+)/? /temp/test.php?string=$1
Mar 10, 2007 at 10:30 AM
I've added your rule and removed the other. But if i access both pages i get "test.php?string=test.php?string=test.php?string=test.php?string=test.php?string=test.php?string=test.php?string=test.php?string=welkom" on the page.

The php-code is:
<?php
echo $string;
?>
Coordinator
Mar 12, 2007 at 5:28 PM
You may need to include a L flag on that rule.

It appears that the rule is being applied multiple times in succession.
The [L} flag will say, if the rule matches once, stop processing; don't try to match any more rules !

Check the readme for more.
or

try the Testdriver program, it should show you the SAME RESULTS !

When in doubt, test it.
Mar 19, 2007 at 3:59 PM
Edited Mar 19, 2007 at 4:02 PM
How about this?

RewriteRule ^/temp/(^/+)(?:/?)$ /temp/test.php?string=$1 L

Seems to work for me. I could be wrong, I'm no RegEx expert.

A better option (which I'm not sure how to write) would be to capture the non-slashed URL and then forward the browser to the slashed URL. But that may be overkill.