需要有关此正则表达式的帮助 +请使用 UrlRewriter.NET :)
(摘要)
我需要捕获所有请求 特定子域..并重写 他们的目的地。
现在,通过正则表达式确定主机的技巧已解决。
现在,我需要确保对根索引页面的所有请求都被重写,但我无法找出正确的正则表达式来查找“主页”/网站根目录。
这就是我所拥有的......
<if header="HTTP_HOST" match="^foo\.mydomain\.com\.au(?::\d+)?/?$">
<!-- snip some other rewrites, eg./buying/product -> ~/Pages/Foo/Bar.aspx -->
<rewrite url="^/$" to="~/Pages/SomeWeirdFolder/Home.aspx" processing="stop"/>
</if>
现在,如果没有找到其中一个重写,那么它就会失败并继续。
那么..有人可以帮忙吗?
更新
我也尝试过 "^$"
、"^~/$"
、"^~?/?$"
...没有运气。
Previously, on StackOverflow ...
(Summarized)
I need to capture all requests, for a
particluar subdomain .. and rewrite
their destination.
Now, the trick to determining the host via regex was solved.
Now, i need to make sure all requests to the root index page is rewritten, but i can't figure out the correct regex to find the 'homepage' / website root.
this is what i have....
<if header="HTTP_HOST" match="^foo\.mydomain\.com\.au(?::\d+)?/?quot;>
<!-- snip some other rewrites, eg./buying/product -> ~/Pages/Foo/Bar.aspx -->
<rewrite url="^/quot; to="~/Pages/SomeWeirdFolder/Home.aspx" processing="stop"/>
</if>
Now if one of the rewrites were not found, then it falls through and continues.
So .. can anyone please help?
UPDATE
I've also tried "^$"
, "^~/$"
, "^~?/?$"
... with no luck.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这有效吗?
Does this work?
您能详细说明一下您想要匹配的内容吗?如果您要匹配的文本仅包含“/”,那么您所拥有的内容应该匹配(除非您需要转义 /,例如 /)。但是,如果您尝试替换的是前导“/”,如 /foo/bar/ 中的 ~/MyPath/foo/bar ,那么我们需要考虑第一个“/”之后的字符
Can you elaborate on what you are trying to match. If the text that you are matching only contains "/" then what you have should match (unless you need to escape /, like /). However if what you are trying to replace is the leading "/", as in /foo/bar/ with ~/MyPath/foo/bar then we need to account for the characters after the first "/"
我发现了问题所在。
站点的根目录是 noit '/',这是默认文档被设置为的文件..在本例中为 '/default.aspx'
之后,一切正常:)
I found out the problem.
The root directory of the site is noit '/', is was the file the default document is being set to .. in this case '/default.aspx'
after that, it all worked :)