开发者

IIS7 URL Rewrite - RegExp to match any string that does not contain a DOT (.)

开发者 https://www.devze.com 2023-01-12 09:12 出处:网络
I am using URL Rewrite module 2 in IIS 7. I have a certain rule for rewriting URLs in IIS. But I want that rule to apply to only strings that DO NOT contain a DOT (.) If the string contains a DOT, I

I am using URL Rewrite module 2 in IIS 7.

I have a certain rule for rewriting URLs in IIS. But I want that rule to apply to only strings that DO NOT contain a DOT (.) If the string contains a DOT, I want it to fail a开发者_JAVA技巧nd simply be not rewritten.

I thought ^([^\.]+) would work but it rejects only strings that start with a DOT.

Examples:

"projects", "about", "contact" should be matched.

"script.js", "default.css" should be rejected.

What is the regular expression I should use?


^([^.]+)$

Your expression is missing the "$" to match the end of the string, so it is successfully matching 1+ occurrences of a non-DOT character and calling it a day.

0

精彩评论

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

关注公众号