1
Answer

How-to-do-url-rewrite

tabu begum

tabu begum

9y
439
1
Hi to all
I am facing problem to rewrite the url for more then 3 pages
iam using urlrewrite http module
<httpModules><add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/></httpModules>

<rewriter>

<rewrite url="~/(.+)-(.+)_aspx" to="~/ViewVideos.aspx?mID=$2"/>
<rewrite url="~/(.+)-(.+)-aspx" to="~/ViewGalery.aspx?GID=$2"/>
<rewrite url="~/(.+)-(.+).aspx" to="~/ViewPage.aspx?TitleID=$2"/>


</rewriter>


the below code i am using inside page
public static string GenerateURL(object Title, object strId)
{
string strTitle = Title.ToString();

#region Generate SEO Friendly URL based on Title
//Trim Start and End Spaces.
strTitle = strTitle.Trim();

//Trim "-" Hyphen
strTitle = strTitle.Trim('-');

strTitle = strTitle.ToLower();
char[] chars = @"$%#@!*?;:~`+=()[]{}|\'<>,/^&"".".ToCharArray();
strTitle = strTitle.Replace("c#", "C-Sharp");
strTitle = strTitle.Replace("vb.net", "VB-Net");
strTitle = strTitle.Replace("asp.net", "Asp-Net");

//Replace . with - hyphen
strTitle = strTitle.Replace(".", "-");

//Replace Special-Characters
for (int i = 0; i < chars.Length; i++)
{
string strChar = chars.GetValue(i).ToString();
if (strTitle.Contains(strChar))
{
strTitle = strTitle.Replace(strChar, string.Empty);
}
}

//Replace all spaces with one "-" hyphen
strTitle = strTitle.Replace(" ", "-");

//Replace multiple "-" hyphen with single "-" hyphen.
strTitle = strTitle.Replace("--", "-");
strTitle = strTitle.Replace("---", "-");
strTitle = strTitle.Replace("----", "-");
strTitle = strTitle.Replace("-----", "-");
strTitle = strTitle.Replace("----", "-");
strTitle = strTitle.Replace("---", "-");
strTitle = strTitle.Replace("--", "-");

//Run the code again...
//Trim Start and End Spaces.
strTitle = strTitle.Trim();

//Trim "-" Hyphen
strTitle = strTitle.Trim('-');
#endregion

//Append ID at the end of SEO Friendly URL
strTitle = strTitle + "-" + strId + ".aspx";

return strTitle;
}
now i want to rewrite the url for sub folder pages
i have the sub floder/En
/En i have the Eviewpage and also Default page
now i want to Rewrite the url for Default page links to Eviewpage
these two pages are present in side sub floder
please help me to find the sollution.
Answers (1)