Tilde ~ causes problem - URL Rewrite

  • Thread starter Thread starter Harsh Trivedi
  • Start date Start date
H

Harsh Trivedi

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...?
 
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
 
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)

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


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...?
 
Hi,

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


Regards

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

Regards,

L.Holota

Harsh Trivedi said:
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)

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


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...?
 
Back
Top