简体   繁体   English

设置 URL 重定向/重写数字

[英]Setup URL redirection/rewrite for numbers

If I have a domain name like "example.com" hosted on IIS.如果我有一个托管在 IIS 上的域名,例如“example.com”。 How can I setup so any URL request with a numeric argument such as example.com/ would be redirected to for instance example.com/function/trigger/?如何设置任何带有数字参数(例如 example.com/)的 URL 请求将被重定向到 example.com/function/trigger/? (where "function/trigger" are hardcoded paths) (其中“函数/触发器”是硬编码路径)

What is the way to do this?这样做的方法是什么? In my index.html, I could add a Javascript function that during load looks for a numeric parameter in the URL and then via javascript calls a redirect method. In my index.html, I could add a Javascript function that during load looks for a numeric parameter in the URL and then via javascript calls a redirect method. However, then the user needs to see/flicker the index.html before getting redirected.但是,用户需要在重定向之前查看/闪烁 index.html。 I would like that this is instant and not recognized that a redirected occurred.我希望这是即时的,并且不承认发生了重定向。

I can't clearly understand what you want to do, but I think it can be done by url rewrite, don't need to use javascript.我不清楚你想做什么,但我认为可以通过 url 重写来完成,不需要使用 javascript。

<rule name="rule" stopProcessing="true">
                <match url="^index/([0-9a-z]+)/([_0-9a-z]+)" />
                <action type="Redirect" url="/function/trigger" />
</rule>

It can match all url containing numeric argument, then redirect it to example.com/function/trigger/.它可以匹配所有包含数字参数的 url,然后将其重定向到 example.com/function/trigger/。

If I have any misunderstanding about your need, you can show me some sample url and redirected url so that I can help you.如果我对您的需求有任何误解,您可以向我展示一些示例 url 并重定向 url 以便我可以帮助您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM