Click here to Skip to main content
15,885,874 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created a URL shortening which converts https://www.moneycontrol.com/news/india/karnataka-election-results-2018-live-updates-missing-mlas-raise-concerns-in-congress-jds-camp-2568569.html

into http://localhost:9909/vrUD4r


now when i hit url http://localhost:9909/vrUD4r it goes to error page!

how can i transfer/redirect http://localhost:9909/vrUD4r to http://localhost:9909/default.aspx?vrUD4r

note that value after http://localhost:9909/ can be any 6 character alphaneumeric! i.e. it can be http://localhost:9909/vrUD4r http://localhost:9909/abCD4E OR http://localhost:9909/ab342D for the different shortened urls.

i manage to shorten the long url, but how can i redirect to original url when i enter short url. i.e. if i enter http://localhost:9909/vrUD4r it must redirect me to original url : https://www.moneycontrol.com/news/india/karnataka-election-results-2018-live-updates-missing-mlas-raise-concerns-in-congress-jds-camp-2568569.html

What I have tried:

I have added default page when i hit http://localhost:9909 it goes to http://localhost:9909/default.aspx
as follows :
<defaultDocument>
   <files>
     <add value="shrtn.aspx" />
   </files>
 </defaultDocument>


also i have tried adding rewrite rule in web.config as follows :

<rewrite>
  <rules>
    <rule name="redirectRule" stopProcessing="true">
      <match url="^/*$" />
      <action type="Redirect" url="/shrtn.aspx/{R:0}" redirectType="Found"/>
    </rule>
  </rules>
</rewrite>
Posted
Updated 17-May-18 21:33pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900