开发者

RewriteRule for URLs that do not end with dot html/php

I would like to redirect all:

<a href="filename"></开发者_StackOverflowa>

to

<a href="get.php?filename"></a>

I have started to

RewriteRule  !\.(html|php)$  /get.php?file=$1 [PT]

But it does not work.


I've tested this regexp in PHP it should work in mod_rewrite but I have not tested it and seems to work in mod_rewrite too:

RewriteRule ^(.+)(?<!\.php)(?<!\.html)$ /get.php?file=$1

The rule will rewrite all URLs except those that end with .php or .html.


The most basic way to handle that is:

RewriteRule ^(.*)$ get.php?file=$1 [QSA,L]

Which will redirect everything, setting file to the value of the path.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜