HELP: BASE and LOCAL paths at the same time?

K

ksamdev

   That is irrelevant. If you specify everything relative to the
   current file, you do not need a BASE tag.

   I have a few sites that I manage this way. On my local machine,
   they are:

     http://cj/cfaj.freeshell.org/
     http://cj/torquiz.freeshell.org/
     http://cj/woodbine-gerrard.com/

   On the Web, they are

     http://cfaj.freeshell.org/
     http://torquiz.freeshell.org/
     http://woodbine-gerrard.com/

   They have no BASE tags. There is no difference between the local
   files and the files on the Web.

   All references are relative to the current file. The sites could be
   moved anywhere and everything would still work.

--
   Chris F.A. Johnson, webmaster         <http://Woodbine-Gerrard.com>
   ===================================================================
   Author:
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

I see, you didn't get my initial point. I have a page that has to use
both paths:

relative to local folder (images specific to current page)
relative to top folder (external resources like: JS, CSS, etc.)

So, question was:

can I specify in my page somehow relation of path whether it has to
be understood by Browser wrt to local folder or top?

Answer: NO.

I can use only one type at a time. Decision was made in account of top
folder. That's why I use BASE link.

My website is heavily loaded with JS and all my libs, scripts should
be using at least relative path to top dir because it is used by
different pages on various levels. This way BASE makes sure everything
works fine.

Downside of current approach - my all img links should be defined
using relative path wrt host that makes it very long. Say:

<img src='pages/articles/1/img/section1/1.png' />

I thought there is some way to get rid of this redundancy especially
if you have say 50 images :). JS may be used for this reason but it's
another complication. My original idea is to keep site as simple as it
can be.
 
C

Chris F.A. Johnson

I see, you didn't get my initial point. I have a page that has to use
both paths:

relative to local folder (images specific to current page)
relative to top folder (external resources like: JS, CSS, etc.)

If it is external, it is not relative to the top folder (or
anything else on your site). If it is not external, it can be
specified relative to the current folder.
So, question was:

can I specify in my page somehow relation of path whether it has to
be understood by Browser wrt to local folder or top?

Answer: NO.

YES!
 
H

Harlan Messinger

ksamdev said:
BTW, this is the exact behavior I found and was really disappointed.
Even HTML 4.01 specification defines that BASE overrides all relative
paths (I am not talking about frames, embedded objects or Flash...
those may have slight differences like CSS external files).

My intuitive feeling was:

./path/img.png treat with respect to BASE element
path/img.png '' '' '' local web-page
path

Unfortunately in both cases BASE is used (if it is set on page of
course) otherwise script current folder is taken as bases.

There isn't any basis for your intuition the BASE tag only works for
URLs that start with a dot. The BASE tag means "for all purposes,
interpret relative URLs on this page relative to *this* URL". And how
could it be otherwise? What if your part of the site was itself on
multiple levels?

http://example.com/mysite/page1.html
http://example.com/mysite/apple/page1.html
http://example.com/mysite/banana/page1.html

How, under the scheme you envisioned, would you create a link in either
of the lower-level pages leading to the higher-level page? If you used
BASE to refer to the production server, then on your development server
that link (whether you coded it as "/mysite/page1.html" or as
"../page1.html") would take you to the live copy of the page, not to the
development copy. How could you specify that you mean the local copy?
 
J

Jonathan N. Little

K

ksamdev

There isn't any basis for your intuition the BASE tag only works for
URLs that start with a dot. The BASE tag means "for all purposes,
interpret relative URLs on this page relative to *this* URL". And how
could it be otherwise? What if your part of the site was itself on
multiple levels?

http://example.com/mysite/page1.htm...mlhttp://example.com/mysite/banana/page1.html

How, under the scheme you envisioned, would you create a link in either
of the lower-level pages leading to the higher-level page? If you used
BASE to refer to the production server, then on your development server
that link (whether you coded it as "/mysite/page1.html" or as
"../page1.html") would take you to the live copy of the page, not to the
development copy. How could you specify that you mean the local copy?

Agree on that.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top