URL rewriting can be done as follows,
void Application_BeginRequest(object sender, EventArgs e) {
string fullOrigionalpath = Request.Url.ToString();
if (fullOrigionalpath.Contains("/Tour/Inner.aspx?Pid=2&Cid=8")) {
Context.RewritePath("/Tour/Goa/new-year-goa");
}
else if (fullOrigionalpath.Contains("/Tour/Inner.aspx?Pid=2&Cid=8&DeptF=ND")) {
Context.RewritePath("/Tour/Goa/new-year-goa");
//This can be something else according to your requirements.
}
}
You can look at this http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
Or else you can modify your web.config to achieve the goal,
here is the sample,
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="rewriter"
requirePermission="false"
type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
</configSections>
<system.web>
<httpModules>
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
</httpModules>
</system.web>
<rewriter>
<rewrite url="~/Tour/Inner.aspx?Pid=2&Cid=8" to="~/Tour/Goa/new-year-goa" />
//Some other re-writers to achieve specific requirements.
</rewriter>
</configuration>
[EDIT: Following Can be one solution]
ok. So as you are saying you need to check pid and cid so redirect accordingly,
One way to achieve this is below,
Request.QueryString("Pid") and Request.QueryString("Cid")
- store them into some variables,
- check those variables with some switch...case mechanism and according to the passed condition set the path using
Context.ReWritePath("Your Specified Path")
The other way to do this is using database,
- create a table containing three columns,
pid, cid, and location_path
- Now get the
cid and pid using above mentioned Request.QueryString
- using sql query, select the location from the table which matchs with the
cid and pid fetched by Request.QueryString and set it using Context.ReWritePath
Hopefully this is clear to you now.
Hope it helps.