fowardslahs problem

Topics: User Forum
Mar 9, 2007 at 6:25 PM

If I visit visit the page 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 1: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 11: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:
echo $string;
Mar 12, 2007 at 6: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.

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

When in doubt, test it.
Mar 19, 2007 at 4:59 PM
Edited Mar 19, 2007 at 5: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.