Tilde ~ causes problem - URL Rewrite

Discussion in 'ASP .Net' started by Harsh Trivedi, Dec 26, 2007.

  1. Hi,

    We have implemented URL rewriting in our site. It all went OK till
    home page links.

    When we click on home page category control, where we have implemented
    rewriting, it works ok, and open subcategory listing page.

    problem comes now...

    on the sub category listing page also, we have implemented url
    rewriting.... but by all surprize it is showing wrong path where we
    have use ~ [tilde].

    E.g. ~/Images/Pen.jgp... the ~ should replace with the configured
    virtual directory, but it resolves the path of ~ with changed URL
    path, that is rewriten.


    I am stuck with this problem, all images and hyperlinks having ~ shows
    wrong path....

    can anyone please help...?
    Harsh Trivedi, Dec 26, 2007
    #1
    1. Advertising

  2. Harsh Trivedi

    Guest Guest

    Hi,

    solved this either, you have to use complete absolute paths like
    http://www.example.com/Images/...., or do it like me :) creare rewrite rules
    with regular expressions - rewrite wrong paths to the right ones. I have my
    own rewriting module, so it was easy...

    Regards,

    Lukas Holota

    "Harsh Trivedi" <> wrote in message
    news:...
    > Hi,
    >
    > We have implemented URL rewriting in our site. It all went OK till
    > home page links.
    >
    > When we click on home page category control, where we have implemented
    > rewriting, it works ok, and open subcategory listing page.
    >
    > problem comes now...
    >
    > on the sub category listing page also, we have implemented url
    > rewriting.... but by all surprize it is showing wrong path where we
    > have use ~ [tilde].
    >
    > E.g. ~/Images/Pen.jgp... the ~ should replace with the configured
    > virtual directory, but it resolves the path of ~ with changed URL
    > path, that is rewriten.
    >
    >
    > I am stuck with this problem, all images and hyperlinks having ~ shows
    > wrong path....
    >
    > can anyone please help...?
    Guest, Dec 26, 2007
    #2
    1. Advertising

  3. We have written like this:

    1) Place the function to rewrite in global.asax file in Begin request
    event
    2) Create the function that will be called by step -1
    3) Create the xml file for url mapping and use Reg ex
    4) Once false path is found for the url,
    HttpContext.Current.RewritePath(newPath)

    On Dec 26, 2:35 pm, <> wrote:
    > Hi,
    >
    > solved this either, you have to use complete absolute paths likehttp://www.example.com/Images/...., or do it like me :) creare rewrite rules
    > with regular expressions - rewrite wrong paths to the right ones. I have my
    > own rewriting module, so it was easy...
    >
    > Regards,
    >
    > Lukas Holota
    >
    > "Harsh Trivedi" <> wrote in message
    >
    > news:...
    >
    > > Hi,

    >
    > > We have implemented URL rewriting in our site. It all went OK till
    > > home page links.

    >
    > > When we click on home page category control, where we have implemented
    > > rewriting, it works ok, and open subcategory listing page.

    >
    > > problem comes now...

    >
    > > on the sub category listing page also, we have implemented url
    > > rewriting.... but by all surprize it is showing wrong path where we
    > > have use ~ [tilde].

    >
    > > E.g. ~/Images/Pen.jgp... the ~ should replace with the configured
    > > virtual directory, but it resolves the path of ~ with changed URL
    > > path, that is rewriten.

    >
    > > I am stuck with this problem, all images and hyperlinks having ~ shows
    > > wrong path....

    >
    > > can anyone please help...?
    Harsh Trivedi, Dec 26, 2007
    #3
  4. Harsh Trivedi

    Med Guest

    Hi,

    Try Page.ResolveUrl("~/Images/Pen.jpg") or
    Page.ResolveClientUrl("~/Images/Pen.jpg") see if it works.


    Regards

    Med



    "Harsh Trivedi" <> wrote in message
    news:...
    > Hi,
    >
    > We have implemented URL rewriting in our site. It all went OK till
    > home page links.
    >
    > When we click on home page category control, where we have implemented
    > rewriting, it works ok, and open subcategory listing page.
    >
    > problem comes now...
    >
    > on the sub category listing page also, we have implemented url
    > rewriting.... but by all surprize it is showing wrong path where we
    > have use ~ [tilde].
    >
    > E.g. ~/Images/Pen.jgp... the ~ should replace with the configured
    > virtual directory, but it resolves the path of ~ with changed URL
    > path, that is rewriten.
    >
    >
    > I am stuck with this problem, all images and hyperlinks having ~ shows
    > wrong path....
    >
    > can anyone please help...?
    Med, Dec 26, 2007
    #4
  5. Harsh Trivedi

    Guest Guest

    I recommend to implement this as an IHttpModule, it's more practical and
    easier to implement to other applications

    Regards,

    L.Holota

    "Harsh Trivedi" <> wrote in message
    news:...
    > We have written like this:
    >
    > 1) Place the function to rewrite in global.asax file in Begin request
    > event
    > 2) Create the function that will be called by step -1
    > 3) Create the xml file for url mapping and use Reg ex
    > 4) Once false path is found for the url,
    > HttpContext.Current.RewritePath(newPath)
    >
    > On Dec 26, 2:35 pm, <> wrote:
    >> Hi,
    >>
    >> solved this either, you have to use complete absolute paths
    >> likehttp://www.example.com/Images/...., or do it like me :) creare
    >> rewrite rules
    >> with regular expressions - rewrite wrong paths to the right ones. I have
    >> my
    >> own rewriting module, so it was easy...
    >>
    >> Regards,
    >>
    >> Lukas Holota
    >>
    >> "Harsh Trivedi" <> wrote in message
    >>
    >> news:...
    >>
    >> > Hi,

    >>
    >> > We have implemented URL rewriting in our site. It all went OK till
    >> > home page links.

    >>
    >> > When we click on home page category control, where we have implemented
    >> > rewriting, it works ok, and open subcategory listing page.

    >>
    >> > problem comes now...

    >>
    >> > on the sub category listing page also, we have implemented url
    >> > rewriting.... but by all surprize it is showing wrong path where we
    >> > have use ~ [tilde].

    >>
    >> > E.g. ~/Images/Pen.jgp... the ~ should replace with the configured
    >> > virtual directory, but it resolves the path of ~ with changed URL
    >> > path, that is rewriten.

    >>
    >> > I am stuck with this problem, all images and hyperlinks having ~ shows
    >> > wrong path....

    >>
    >> > can anyone please help...?

    >
    Guest, Dec 27, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jared Tullis
    Replies:
    11
    Views:
    3,121
    shekharshashi2000
    Mar 28, 2008
  2. Karo

    Tilde (~) in url

    Karo, Jul 5, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    7,061
    Oleg Ogurok
    Jul 5, 2005
  3. =?Utf-8?B?VA==?=

    Rewrite asp url as aspx url?

    =?Utf-8?B?VA==?=, Jul 22, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    673
    gerry
    Jul 24, 2005
  4. ibiza
    Replies:
    8
    Views:
    34,202
    whizsid
    Jul 3, 2008
  5. Martin
    Replies:
    0
    Views:
    1,199
    Martin
    Apr 28, 2010
Loading...

Share This Page