Home All Groups Group Topic Archive Search About

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

Author
16 Jun 2009 8:56 PM
Jeff
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?

Author
16 Jun 2009 9:04 PM
Evertjan.
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)
Are all your drivers up to date? click for free checkup

Author
17 Jun 2009 2:01 AM
jeffctest-google@yahoo.com
"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.
Author
17 Jun 2009 8:12 AM
Adrienne Boswell
Gazing into my crystal ball I observed
=?Utf-8?B?amVmZmN0ZXN0LWdvb2dsZUB5YWhvby5jb20=?=
<jeffctest-goo***@yahoo.com> writing in
Show quoteHide quote
news:C6AD951E-20DA-4B01-AD20-DDB2F627C5DF@microsoft.com:

> "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 .

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share
Author
17 Jun 2009 3:03 PM
Evertjan.
Adrienne Boswell wrote on 17 jun 2009 in
microsoft.public.inetserver.asp.general:

Show quoteHide quote
> Gazing into my crystal ball I observed
> =?Utf-8?B?amVmZmN0ZXN0LWdvb2dsZUB5YWhvby5jb20=?=
> <jeffctest-goo***@yahoo.com> writing in
> news:C6AD951E-20DA-4B01-AD20-DDB2F627C5DF@microsoft.com:
>
>> "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)
Author
17 Jun 2009 3:26 PM
Adrienne Boswell
Gazing into my crystal ball I observed "Evertjan."
<exjxw.hannivo***@interxnl.net> 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
Author
17 Jun 2009 9:33 PM
jeffctest-google@yahoo.com
"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.
Author
19 Jun 2009 1:09 PM
jeffctest-google@yahoo.com
Show quote Hide quote
"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!
Author
19 Jun 2009 1:20 PM
Daniel Crichton
jeffctest-goo***@yahoo.com wrote  on Fri, 19 Jun 2009 06:09:01 -0700:

Show quoteHide quote
> "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

Bookmark and Share