我创建了一个功能,可以将长网缩短为短网址。与bit.ly和google url shortener相同 例如,
到http://hostname/snKcxi(http://localhost:9909/snKcxi)
我创建了一个页面http://localhost:9909/shrtn.aspx,它应该从网址http://localhost/snKcxi获取网址密钥值:snKcxi,然后将控制转移到原始的长网址,即如果我点击http://localhost:9909/snKcxi,它应该重定向到: https://www.moneycontrol.com/news/india/karnataka-election-results-2018-live-updates-missing-mlas-raise-concerns-in-congress-jds-camp-2568569.html
我尝试过网址重写,例如:
<rewrite>
<rules>
<!-- For URL redirect-->
<rule name="redirectRule" stopProcessing="true">
<match url="^http://localhost:9909/$" />
<action type="Redirect" url="http://localhost:9909/shrtn.aspx" redirectType="Found"/>
</rule>
</rules>
</rewrite>
但它无法完成备受推崇的功能。当我点击http://localhost/snKcxi时,它会转到404错误页面! 谁能帮我吗?任何建议或改变??
我想做的是从短网址获取密钥(我将根据密钥从数据库中搜索长网址) 然后将其转移到长URL
答案 0 :(得分:0)
在web.config文件中添加了以下规则&amp;问题解决了。
@users