How to r开发者_如何学JAVAedirect url`s like this
http://example/foo/bar/
http://example/foo/bar
to
http://example/foo/bar.php
Here is my rewrite rule
RewriteRule ^(.*)$ $1.php
It works with http://example/foo/bar but if the url is ending with slash a error rise (Internal Server Error) What to to do so both url types to work properly ?
It's because the / got matched in the group .*, so you call http://example/foo/bar/.php
To make both works use :
RewriteCond %{REQUEST_URI} !\.php
RewriteRule ^(.*)/?$ $1.php
EDIT: forget when we ask a file in the first place
Well, if this is really what you want to do, then:
RewriteRule ^(.*)/?$ $1.php
I haven't tested this, but I think it works.
精彩评论