What is the regular expression to match the empty string for a rewrite rule?

爱⌒轻易说出口 提交于 2019-12-22 05:00:45

问题


I need a regular expression for a rewrite rule on iis7, I'm trying to redirect http://www.website.com to http://www.website.com/sample. But I only want the empty url string (extra points if you can figure it out with and without '/'), and I'm unsure how to create a rewrite rule to match to that.

Can someone help me out here?


回答1:


^/?$

I think...




回答2:


not exactly sure what your looking for but this matches an empty url strip:

http//\Z




回答3:


The question isn't very clear, but I think you want this:

^http://www.website.com/?$

The ^ and $ match the beginning and end of the string. The /? optionally matches a trailing slash.



来源:https://stackoverflow.com/questions/1473632/what-is-the-regular-expression-to-match-the-empty-string-for-a-rewrite-rule

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!