简体   繁体   中英

Setup URL redirection/rewrite for numbers

If I have a domain name like "example.com" hosted on IIS. 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/? (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. However, then the user needs to see/flicker the index.html before getting redirected. 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.

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

If I have any misunderstanding about your need, you can show me some sample url and redirected url so that I can help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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