Not sure whether this is a pathauto problem.
Creating a page at node/3 pathauto changes the url to http://domain.net/content/welcome
I'm linking to an image from the content of this node using:
<img src='sites/default/files/prospectus/parent/director.jpg' />
But the image doesn't appear in the content because the url for the image becomes:
<img src='http://domain.net/CONTENT/sites/default/files/prospectus/parent/director.jpg' />
That is not the path to the image. The real path of the image is:
<img src='http://domain.net/WEB/sites/default/files/prospectus/parent/director.jpg' />
Can anyone enlighten me as to what is going on?
I didn't expect pathauto to change my embedded image urls AT ALL.
I really don't want to use absolute urls for all my images, because at somepoint I may change the 'web' sudirectory name, or move the drupal install into root.
Thanks.
Comments
Comment #1
-Anti- commentedOK, I just discovered that it works fine if I use:
<img src='/WEB/sites/default/files/prospectus/parent/director.jpg' />However, that's not a very good 'relative' url is it?
Having to put the subdirectory into the url defeats the whole purpose of 'relativity'.
Is this a drupal core problem, or a pathauto problem, or both?
To me, this is a huge critical bug, and I can't really believe what I'm seeing.
It basically means that drupal installations are not portable!!?
Thanks for any info/insight.
Comment #2
Freso commentedThis is neither Pathauto nor Drupal - it's simply the way the web works. If I make a relative link from here, say to "foo", the browser (ie., not Drupal or anything else on the webserver) would interpret that as http://drupal.org/node/294924/foo. Another way of marking relative URLs is using "/". The "/" denotes that we're working from the root now, instead of the current location, meaning that "/foo" will now be interpreted as http://drupal.org/foo. Thirdly, there's the absolute URL, but you know all about that, I'm sure. :)
To use your example, when you're at "http://domain.net/content/welcome" and want to go to "sites/default/files/prospectus/parent/director.jpg", the browser will treat that as "http://domain.net/content/sites/default/files/prospectus/parent/director..." - go ahead and check the server's error log. You will find 404s for that URL. :) To make relative URL go the proper place, you'll have to reverse a couple of directories, like so: "../sites/default/files/prospectus/parent/director.jpg". (Also note that there's a big difference between "http://domain.net/content/welcome" and "http://domain.net/content/welcome/".)
I'm sure there are places explaining it in more depth around the web, so feel free to look up more information on how relative URLs work, if I didn't explain them well enough! :)
Comment #3
Freso commentedEh. I initially meant to change project, but I didn't mean to when I posted the answer in the end... :x
Comment #4
-Anti- commentedThanks for your reply.
I started another thread to take this further, as I need more information about 'best practice'.
http://drupal.org/node/294983
Cheers.
Comment #5
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.