Free

Free coded apps to suit all. No sign up, no email, usable offline, updates when I can, feedback welcome. Send feedback

Thinking

What happens to links when you rename files on a server

Renaming a server file breaks every link to its old name. FTP by Zaweba's link awareness finds those links in your local site and rewrites them.

What happens to links when you rename files on a server

Nothing updates them by itself. A web server serves files by name, so the moment a file is renamed or moved, every page, stylesheet and script that asked for the old name gets a missing file instead. FTP by Zaweba handles this with link awareness: after a rename or move in Disk, it lists the references to the old paths in your linked local site and can rewrite them for you, undoably.

It helps to understand why links are so fragile, because it changes how you plan any tidy up.

Why a rename breaks things

A link is only text. When a page says img src="images/shop front.jpg", the browser asks the server for that exact path. The server doesn't know or care that you renamed the file to shop-front.jpg a minute ago. It looks for the old name, finds nothing and returns an error, and the visitor sees a broken picture or a page not found.

The same goes for stylesheets linked from the head of a page, scripts, background images named inside CSS, includes in PHP and rules in .htaccess that mention a path. A single renamed file can be referred to from dozens of places.

Links from outside your site are a separate matter. Search engines, other websites and people's bookmarks know the old address too, and nothing on your PC can change those.

How link awareness fixes your own links

When you rename or move files on the server from Disk, whether one at a time or with bulk rename, FTP by Zaweba then looks through the linked local site. It reads .php, .html, .css, .js and .htaccess files and lists every reference to the old paths.

You tick the ones to fix and press Update references locally. The rewrite keeps the style each link was written in. A relative link stays relative, a link from the root of the site stays rooted, and a full address with the domain stays full. Query strings and fragments, the parts after a question mark or a hash, are kept as they were. The window tells you what it found, so you decide what changes.

Only local files are edited, and the change can be undone. That is a deliberate line: your local copy is where you edit, and nothing is sent to the server until you choose to upload.

Getting the fixes onto the server

After updating references, the changed pages exist only on your PC. Upload them. Put Newer to Server is a good fit, because it lists exactly the local files newer than the server copies before anything is sent. If Upload on Save is your habit, opening and saving each page also works, but Put Newer is quicker for a batch.

Then check the pages in Live Preview. The preview console lists resources that fail to load, with their file and line, so a missed reference shows up as a clear message rather than a picture you might not notice is missing.

Thinking about outside links

For pages that people outside your site link to, a redirect from the old address to the new one keeps visitors arriving. On ordinary hosting that is usually a rule in .htaccess. FTP by Zaweba's editor has syntax colours for Apache .htaccess, and Disk protects that file from being renamed or moved, so the rule you add stays put.

Pictures and stylesheets rarely need redirects, since nobody bookmarks them. Pages do.

Is renaming worth it at all

Often, yes. Clean, consistent names make a site easier to look after for years. The cost used to be broken links and an afternoon of searching. With link awareness the cost is a tick list and an upload, and if anything goes wrong the operations log can undo the rename as a batch. The sensible approach is to rename deliberately, fix the links straight away, and not leave it for later.