If you're moving an entire folder with files that reference other files on the site, it should automatically update links, or at least prompt you. But even if you have to do it manually, a simple FIND AND REPLACE (ctrl+F) operation will do it all in one click.
I probably didn't phrase it exactly.
I move a file from the root folder to a subfolder.
The links do update. As in 'filename.php' becomes '../filename.php'.
But the images that are inside the linked files no longer show (or only some of them) and their "alt text" appears.
When trying (as much suggested) to change the the image src= from image/filename.whatever to /image/filename.whatever, the images entirely disappear.
Thanks for response.
Are the links inside PHP code, or are they within the HTML portion of the code? Can you show us an example of the page uploaded somewhere?
Within the HTML
This code works on file at the root level:
<?php require_once('header.php'); ?>
This is what DW does to it when its moved to a subfolder:
<?php require_once('../header.php'); ?>
The HTML in either case is the same in a header.php file at the root level:
img src="Images/header_banner.jpg"; et. al. (other banner; footer images)
When file operates at the root level, everything shows up fine in live view, localhost test, and remote servers on IE, Safari, and Firefox
When I move file to a subfolder, DW adds the ../ the HTML remains the same and the images only partially load and their "alt text" shows.
Tried adding the / in front of Images as such: img src="/Images/header_banner.jpg" and then the images do not show at all.
Don't have the site up on remote right now. Does this code give you enough info?
1 person found this helpful
>But the images that are inside the linked files
>no longer show (or only some of them) and their "alt text" appears.
That is correct. Links are resolved from the containing document, not the included file, so moving to a different level will break it. That's why I think it's always easier to use site root relative links with SSI.
OK then: how is it done/corrected?
When I tried following other instructions on converting to a site root relative link - it didn't work.
Any very good instructions on this?
Thanks for reply.
Site relative links are pretty simple. (I work on Linux servers, I don't know if this info is different for other environments.)
When you want something to point to a location relative from where you currently are, just type the path without the preceding slash. For example, if you are working on a page in your site root, and you are linking to an image that is in a folder called "images" which is also off the root (meaning, it is lateral to your current document), you would put:
Putting ../ before the url backs you up one level. So, if you were working on a page that was located at root --> documents --> manuals --> links.php you and in that page you used
it's going to look for "picture.jpg" in the "documents" folder, because it's one level higher than your current "links.php". You can also do more than one to back up multiple levels.
would look for "picture.jpg" within the root.
Beyond all that, if you use a preceding slash, it will default to the document root and work from there. In the same example as above, if you put:
it's going to look for "picture.jpg" in the folder called "extras" off the site root, even though you were several layers deep when you used it.
This is how it all works on my servers, which as I said are Linux.
Thanks so much, but this does not work in my case.
After many, many experiments and garnering one tid-bit of information after another from many different on-line posts (not just the DW forum), I finally figured it out.
Document relative links are automatically converted to site root relative links by Dreamweaver when you use File Panel to move a file into a newly created subfolder. You could create your own site root relative links should you start a file from scratch within a subfolder that had to link up, down, or through to another level, but DW will do this for you if you move files about using File Panel.
That said, there is something that does not work and in spite of what (bregent) wrote, it is an issue that you need to use DW to resolve, at least if you are going to successfully display and test at the local level. The problem involves using SSI (Site Server Includes). In my case, it involved calling up php files for the header and footer. Both of these files (which are simply the HTML code for the header and footer) resided in the root level folder and operated just fine when called by another page file within the same root folder. But when moving a page file into a subfolder, all of the document relative links in that particular folder were changed accordingly, including the SSI call for the header.php and footer.php files (i.e. it went from ...require_once('header.php')... to ...require_once('../header.php')...) but, but, but, but, but: the actual file header.php (and footer.php) still had exactly the same document relative link (i.e. src="Images/filename.gif"). And while this continued to return the correct image, placement, etc. in any page file remaining in the root folder, anything moved into a subfolder causes the links to break, or I should say, to not show properly. No matter how many times and ways you try to make the header.php file links into root relative links, (without doing what I state below), they will not work properly for the subfolders.
So what was the answer? A tad bit complex, but perhaps not really in the end.
First a couple of facts: because the SSI command (in this case for php:) <?php require_once('header.php'); ?> (or ('../header.php'), whatever is the case and folder level) ... because the SSI command returns the header.php file to the particular page while the server is operating, the page thinks the header.php file is located at whatever level the internal link (i.e. src="Images/filename.gif") says the level is, and if it actually is not located at that level, it can't find it. Trying to simply add a forward slash "/" in front does not help when the page is running on a server, because the server doesn't know where to start the root search (in my case, using WAMP as the local php server "localhost") unless you use Dreamweaver to do the following: (and here is the solution):
You have to go into "Manage Sites" and edit the http address just above where it says: "This address is used for site relative links . . ." ((Don't need to change the nereby radio button selection from Document Relative to Site Relative, I wouldn't necessarily recommend it)) Normally, you need to have this pointing to the root folder on your remote site (so DW files being put to the remote site operate properly when working with the remote site through DW). But if, as in my case, you want to test locally, and have all SSI files work, you have to reset this to the localhost address (in the local info section of advanced in the edit sites section of manage sites), in my case using WAMP: :http://localhost/rootdirectory/ Then when server-side dynamic calls are made, in this case looking for a php file named "header.php" it knows where to begin to look for the links that are written inside the called up HTML code. The second part of this is to add a definitive site root relative link inside the particular HTML that is being called. A simple "/" will not work. You have to state: img src="/rootdirectory/folder/filename.gif" in order to tell the server where to look. In my case this is "img src=/rootdirectory/Images/header_banner.jpg" (where "rootdirectory" is the actual site folder name) After doing these two steps, (1)changing the http address in local info, and (2) adding the more definitive root relative lead to the actual image file; the php delivered header and footer behave exactly as they should whether a page is located in the same root folder or in a subfolder.
When going to the remote level: I have not done this following yet, but it makes sense, and there are discussions on-line about doing this. When you decide to put the site to remote, you perform a Find/Replace function to change the /rootdirectory/ call on these particular image links (in my case it is only 3 total image files for the header and footer) to the exact rootdirectory name on the remote server (in my case "/public_html/"). You'll only need to do this for the SSI called files that have this type of image link being used by other page files located in numerous sub folders. And, and, and, you'll have to remember to change manage sites, edit sites, advanced, local info "This address is used for site relative links . . ." back to the actual address of the remote server (http://www.site.com/ftp@.. . ./public_html/)(or whatever your hosting service tells you to use for the actual full address to your remote site root directory.
In all, in was extremely complicated for me to understand at first, but in reality, it is a pretty simple fix. Remember, it is only needed when you have SSI called files that have links in folders other than the subfolders to which page files have been moved. You do not need to do this for regular site relative links and it won't affect them anyway.
Hope this helps someone else. I found most stuff out there on this to be very un-thorough in answer or incorrect in direction. It is a Dreamweaver issue, in the fact that you can use DW to fix it.
BTW: Michael and others, thnx for help - spurred ideas!