Link to home
Start Free TrialLog in
Avatar of boricua1213

asked on

Get relative path?

How to get relative path from root.  In i can use ResolveUrl("~/page.aspx') to get the path from where ever the user is at in the directory structure back to root to get to page.aspx.  Is there a way to do this in classic ASP?
Avatar of jitganguly

Avatar of boricua1213


Wouldn't that give me the physical path?  C:\site\page.aspx
Ok Try this

Avatar of Mark Franz
So what is it you want?  The following script;

Response.Write Request.ServerVariables("PATH_INFO") & "<br>"
Response.Write Request.ServerVariables("PATH_TRANSLATED") & "<br>"
Response.Write Request.ServerVariables("APPL_PHYSICAL_PATH") & "<br>"
Response.Write Request.ServerVariables("SCRIPT_NAME") & "<br>"
Response.Write Request.ServerVariables("SERVER_NAME") & "<br>"
Response.Write Request.ServerVariables("URL") & "<br>"

Provided these results;

Say I am viewing a page in here:

and in test.asp I want to know how to get to

Now in I can use ResolveUrl("~/scripts/test.js")  that will return ../scripts/test.js if it was an aspx page.  That is what I need in asp.

U might be thinking oh just put a slash in front the resource like "/scripts/test.js".  In this example this will work, but if the applications root was in a directory below the domains root, such as:  Now if I try to use the slash the browser will look for test.js at  But it is actually at  In the ResolveUrl will return the correct URL.

You might be asking your self y i'm i using asp instead of .net.  I need to set a variable in third party asp app.

Thank you in advance
Avatar of Mark Franz
Mark Franz
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
My input seems to be the best response.
How would I use this function to set a vir_path to a file? To get away from all the ../../ in the includes on asp pages.
Example; wwwroot/folder1/folder2/folder3/somefile.asp
So all the includes would point to virtual/scripts/pathfile.asp