TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
tabu begum
NA
252
859
How-to-do-url-rewrite
Sep 18 2015 4:09 AM
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.
Reply
Answers (
1
)
Developer's Knowledge
even and odd values