开发者

Need help with this Regex + UrlRewriter.NET please :)

开发者 https://www.devze.com 2022-12-26 09:23 出处:网络
Previously, on StackOverflow ... (Summarized) I need to capture all requests, for a particluar subdomain .. and rewrite

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+)?/?$">
    <!-- snip some other rewrites, eg./buying/product -> ~/Pages/Foo/Bar.aspx -->
    <rewrite url="^/$" to="~/Pages/SomeWeirdFolder/Home开发者_StackOverflow.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.


Does this work?

<rewrite url="^/?$" to="~/Pages/SomeWeirdFolder/Home.aspx" processing="stop"/>
<!-- -----------^ -->


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 "/"


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 :)

0

精彩评论

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

关注公众号