Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 3 of 3

Thread: URL rewrite question

  1. #1
    MichaelCN is offline Junior Member
    Join Date
    Apr 2009
    Posts
    3

    Default URL rewrite question

    There is a <a> tag in my page like: <a href="p-12-shirt.aspx">sport</a>.
    If I change the tag to <a href="welcome">sport</a>, I still want to enter the "p-12-shirt.aspx" page but the url in the browser need to be "localhost/XXX/welcome".

    What can I do?

    I noticed that there was a "Custom_Application_BeginRequest_Logic" in the AppLogic.cs file.

    I write:
    public static bool Custom_Application_BeginRequest_Logic(Object sender, EventArgs e)
    {
    string Path = HttpContext.Current.Request.Url.ToString();
    Path = Path.Substring(Path.LastIndexOf("/")+1).ToLowerInvariant();//get the "welcome"
    if(Path == "welcome")
    {
    HttpContext.Current.RewritePath("p-12-shirt.aspx");
    }
    return false;
    }

    However, when I click the <a> tag, the url is changed to "http://localhost/XXX/Come.ttt" but the page can't be found.

  2. #2
    ASPDNSF Staff - Jon's Avatar
    ASPDNSF Staff - Jon is offline Senior Member
    Join Date
    Sep 2004
    Posts
    11,419

    Default

    Add a new rewrite rule to the < urlrewrites > section of \web\web.config:
    Code:
    <rule url="/welcome\.aspx" rewrite="/showproduct.aspx?ProductID=12&amp;SEName=shirt" />
    Jon Wolthuis

  3. #3
    samindianic is offline Junior Member
    Join Date
    Sep 2009
    Posts
    2

    Default URL Rewrite

    Hi,
    there is url news.aspx?showarticle=1 but i want 1.aspx how can i do it.where should i write the code .Please reply me soon