Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > How to change all relative paths in a website???

Reply
Thread Tools

How to change all relative paths in a website???

 
 
Jeff
Guest
Posts: n/a
 
      06-16-2009
I have thousands of ASP files and a lot of them use relative paths to
various folders like an images folder so the path looks from the root
like "/images/whatever.jpg". Now I have been told that the URL has to
have a folder at the end such as "whatever.com/mine/" which in effect
is turning the new root into /mine. That means all my relative paths
won't work and the only solution I can think of is I have to change
EVERY file that uses a relative path and either hard code the new "/
mine/" at the beginning or use an application variable to specify what
the root is and still hard code that at the beginning of each relative
path.

Obviously I don't want to spend the time it would take to hopefully
find every relative path in every file and make this work. I have
control of the server so can change IIS.

Is there a solution that will globally make this works so there aren't
a ton of changes?
 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      06-16-2009
Jeff wrote on 16 jun 2009 in microsoft.public.inetserver.asp.general:

> I have thousands of ASP files and a lot of them use relative paths to
> various folders like an images folder so the path looks from the root
> like "/images/whatever.jpg". Now I have been told that the URL has to
> have a folder at the end such as "whatever.com/mine/" which in effect
> is turning the new root into /mine.


This sounds illogical.

Unless it is the defaultfile in a directory,
the filename should be at the end of the URL.


> That means all my relative paths won't work


Why?

Because you have been told, or because it is?

> and the only solution I can think of is I have to change
> EVERY file that uses a relative path and either hard code the new "/
> mine/" at the beginning or use an application variable to specify what
> the root is and still hard code that at the beginning of each relative
> path.


Use

<base href='/'>

if your relative point should be the root.

This is really not an ASP, but a html issue.
If so it is off topic.

> Obviously I don't want to spend the time it would take to hopefully
> find every relative path in every file and make this work. I have
> control of the server so can change IIS.
>
> Is there a solution that will globally make this works so there aren't
> a ton of changes?


Please first be clearer on what really happened.
Did your siteprovider change some settings?



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
 
 
 
jeffctest-google@yahoo.com
Guest
Posts: n/a
 
      06-17-2009
"Evertjan." wrote:

> This sounds illogical.
>
> Unless it is the defaultfile in a directory,
> the filename should be at the end of the URL.


You're right. It is illogical. Let me try to make it a little clearer. The
website sits on an Intranet and in IIS, it's the Default Web Site. Now to
have this website accessible to the Internet, there is a server that
basically has an alias which points to a location on the Intranet website, in
this case the root /. For some illogical reason, this other server creates
the alias with a folder after the URL as in "whatever.com/mine/". Probably
not clear as to any of this but I'll continue.

So accessing the Intranet website using this new alias, turns the root of
the website now into /mine instead of /. So all the relative paths of images,
style sheets, etc. are now looking for a folder above where the new root is.
For example, this was a valid images path "/images/myimage.gif" but now it
really needs to be "/mine/images/myimage.gif". I wasn't told this, I
determined that's why it was failing.

I was hoping that there was something I'm not thinking of like creating a
virtual directory or something in IIS that would solve everything immediately
instead of having to edit every file that has a relative path. The Base Href
would still require editing all those files, but at least that's only one
addition rather than multiple changes in a file. But there still has to be an
easier way.

And I'm not even going to mention the .NET virtual directory that probably
has the same problem.

Hopefully that helps to clear things up. Thanks for replying and I'm hoping
there is an easy solution.
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      06-17-2009
Adrienne Boswell wrote on 17 jun 2009 in
microsoft.public.inetserver.asp.general:

> Gazing into my crystal ball I observed
> =?Utf-8?B?amVmZmN0ZXN0LWdvb2dsZUB5YWhvby5jb20=?=
> <(E-Mail Removed)> writing in
> news:(E-Mail Removed):
>
>> "Evertjan." wrote:
>>
>>> This sounds illogical.
>>>
>>> Unless it is the defaultfile in a directory,
>>> the filename should be at the end of the URL.

>>
>> You're right. It is illogical. Let me try to make it a little clearer.
>> The website sits on an Intranet and in IIS, it's the Default Web Site.
>> Now to have this website accessible to the Internet, there is a server
>> that basically has an alias which points to a location on the Intranet
>> website, in this case the root /. For some illogical reason, this
>> other server creates the alias with a folder after the URL as in
>> "whatever.com/mine/". Probably not clear as to any of this but I'll
>> continue.
>>
>> So accessing the Intranet website using this new alias, turns the root
>> of the website now into /mine instead of /. So all the relative paths
>> of images, style sheets, etc. are now looking for a folder above where
>> the new root is. For example, this was a valid images path
>> "/images/myimage.gif" but now it really needs to be
>> "/mine/images/myimage.gif". I wasn't told this, I determined that's
>> why it was failing.
>>
>> I was hoping that there was something I'm not thinking of like
>> creating a virtual directory or something in IIS that would solve
>> everything immediately instead of having to edit every file that has a
>> relative path. The Base Href would still require editing all those
>> files, but at least that's only one addition rather than multiple
>> changes in a file. But there still has to be an easier way.
>>
>> And I'm not even going to mention the .NET virtual directory that
>> probably has the same problem.
>>
>> Hopefully that helps to clear things up. Thanks for replying and I'm
>> hoping there is an easy solution.
>>

>
> I think there is something you can do in IIS - I seem to remember having
> to do that a long time ago with some IIS server somewhere, but alas, I
> don't remember what I did.
>
> You might want to check in an IIS group, like
> microsoft.public.inetserver.iis .



I would catch all nonexisting calls that end up in 404.asp,
and response.redirect or server.transfer them to the factual url.

A simple all inclusive solution, if only you prevent the reentry of urls
that are not available under /mine/, which the below does automagically:

=================== 404.asp ================

<%

qstr = lcase(Request.ServerVariables("QUERY_STRING"))

if instr(qstr,":80/mine/")=0 then
p = instr(qstr,":80/")
url = mid(qstr,P+3)
server.transfer "/mine/" & url
end if

%>

This is the 404 page, the page you requested does not exist.

============================================

Please test and adapt to your own peculiar situation.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Adrienne Boswell
Guest
Posts: n/a
 
      06-17-2009
Gazing into my crystal ball I observed "Evertjan."
<(E-Mail Removed)> writing in news:Xns9C2DAD9711BC6eejj99@
194.109.133.242:

> automagically


I love that word!

Usage: My van was automagically turned into a Mercedes!
Citation: Evertjan

(trying to get it into Merriam Webster)

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

 
Reply With Quote
 
jeffctest-google@yahoo.com
Guest
Posts: n/a
 
      06-17-2009
"Evertjan." wrote:
> I would catch all nonexisting calls that end up in 404.asp,
> and response.redirect or server.transfer them to the factual url.
>
> A simple all inclusive solution, if only you prevent the reentry of urls
> that are not available under /mine/, which the below does automagically:


That would work great for the relative path files but not for images, style
sheets, etc. that are within those files.
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      06-18-2009
=?Utf-8?B?amVmZmN0ZXN0LWdvb2dsZUB5YWhvby5jb20=?= wrote on 17 jun 2009 in
microsoft.public.inetserver.asp.general:

> "Evertjan." wrote:
>> I would catch all nonexisting calls that end up in 404.asp,
>> and response.redirect or server.transfer them to the factual url.
>>
>> A simple all inclusive solution, if only you prevent the reentry of
>> urls that are not available under /mine/, which the below does
>> automagically:

>
> That would work great for the relative path files but not for images,
> style sheets, etc. that are within those files.


Oh yes, it works fine for any file redirection,
as there is no clientside coding involved.

Requests made to the server are never requested by the browser in a
"relative" way, the browser always has to resolve the call to an absolute
URL.

The server doesn't even know what type of file it sends.
[Only if it is an asp coded file, the file will be rendered into a
stream, but that has no influence on the working of my code.]

I repeat the skipped code part of mine here:
=================== 404.asp ================
<%

qstr = lcase(Request.ServerVariables("QUERY_STRING"))

if instr(qstr,":80/mine/")=0 then
p = instr(qstr,":80/")
url = mid(qstr,P+3)
server.transfer "/mine/" & url
end if

%>

This is the 404 page, the page you requested does not exist.
============================================


So the url of any file, page, image, styesheet, etc that cannot be found
is converted to the same url string with /mine/ inserted between the
domainand the rest of the url, unless the /mine/ was already in it's
place in the url.




--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
jeffctest-google@yahoo.com
Guest
Posts: n/a
 
      06-19-2009
"Evertjan." wrote:

> =================== 404.asp ================
>
> <%
>
> qstr = lcase(Request.ServerVariables("QUERY_STRING"))
>
> if instr(qstr,":80/mine/")=0 then
> p = instr(qstr,":80/")
> url = mid(qstr,P+3)
> server.transfer "/mine/" & url
> end if
>
> %>
>
> This is the 404 page, the page you requested does not exist.
>
> ============================================


Thanks for the suggestion but it didn't work in my case. I'm just going to
bite the bullet and do a search and replace for every "/ and but instead of
hard coding "/mine/ I'll use an application variable. That way in case it
ever changes again, I only need to change it in one place. Thanks for the
help!

 
Reply With Quote
 
Daniel Crichton
Guest
Posts: n/a
 
      06-19-2009
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote on Fri, 19 Jun 2009 06:09:01 -0700:

> "Evertjan." wrote:


>> =================== 404.asp ================


>> <%


>> qstr = lcase(Request.ServerVariables("QUERY_STRING"))


>> if instr(qstr,":80/mine/")=0 then p = instr(qstr,":80/")
>> url = mid(qstr,P+3)
>> server.transfer "/mine/" & url end if


>> %>


>> This is the 404 page, the page you requested does not exist.


>> ============================================


> Thanks for the suggestion but it didn't work in my case. I'm just going
> to bite the bullet and do a search and replace for every "/ and but
> instead of hard coding "/mine/ I'll use an application variable. That
> way in case it ever changes again, I only need to change it in one
> place. Thanks for the help!


As that will only work in ASP scripts, setting /mine to an Application Root
in IIS will achieve the same result (I think). It still won't correct any
non-ASP references though, such as in HTML, CSS, and Javascript, but as
these wouldn't be using an application variable there's little you can do
about those other than a hardcoded replace.

--
Dan


 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      06-19-2009
Daniel Crichton wrote on 19 jun 2009 in
microsoft.public.inetserver.asp.general:

> (E-Mail Removed) wrote on Fri, 19 Jun 2009 06:09:01 -0700:
>
>> "Evertjan." wrote:

>
> >> =================== 404.asp ================

>
> >> <%

>
> >> qstr = lcase(Request.ServerVariables("QUERY_STRING"))

>
> >> if instr(qstr,":80/mine/")=0 then p = instr(qstr,":80/")
> >> url = mid(qstr,P+3)
> >> server.transfer "/mine/" & url end if

>
> >> %>

>
> >> This is the 404 page, the page you requested does not exist.

>
> >> ============================================

>
>> Thanks for the suggestion but it didn't work in my case. I'm just
>> going to bite the bullet and do a search and replace for every "/
>> and but instead of hard coding "/mine/ I'll use an application
>> variable. That way in case it ever changes again, I only need to
>> change it in one place. Thanks for the help!

>
> As that will only work in ASP scripts,


Sorry, what do you mean?

The above is an asp script, and it only needs to be in entered in a
dedicated 404.asp page. [the use of such 404.asp page needs to be set in
IIS, of course]

Then it will work for .jpg, for .pdf, for .asp, for .html, etc.

If it "does not work" as expected the OP could please say what it does
not do.

You could try response.redirect in stead of server.transfer.

Did you try?


> setting /mine to an Application
> Root in IIS will achieve the same result (I think).


could be.

> It still won't


Please take out the "still"

> correct any non-ASP references though, such as in HTML, CSS, and
> Javascript, but as these wouldn't be using an application variable
> there's little you can do about those other than a hardcoded replace.





--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Paths, gentleman, paths Ohad Lutzky Ruby 2 11-07-2006 02:15 AM
Re: Relative Paths Curt_C [MVP] ASP .Net 1 05-26-2004 12:46 PM
ImageURL not accepting/working relative paths??? Kathy Burke ASP .Net 0 11-14-2003 03:22 PM
Convert between Windows style paths and POSIX style paths Noah Python 5 07-11-2003 09:25 PM



Advertisments