2

I am trying to write a RewriteRule that will match files by their extension, and what I've come up with is:

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On
    RewriteRule ^([^.]*\.less)$ ./index.php?f=$1
</IfModule>

This works fine when the only dot in the filename is the one separating the extension, but fails when there are other dots in there. For example, it won't work for hello.world.less.

I have no clue on how to proceed from here, any help will be much appreciated. Thanks!

4

2 回答 2

2

尝试

^(.*\.less)$ 

这仍然强制最后一个点存在。

于 2013-08-04T19:04:52.980 回答
1

尝试仅删除该字符类,然后.改用:

RewriteRule ^(.*\.less)$ ./index.php?f=$1

.less这将匹配任何以任何其他字符结尾的文件名。

于 2013-08-04T19:04:43.990 回答