Free

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

Workflows

Fixing broken links after a rename in FTP by Zaweba

After you rename or move server files, FTP by Zaweba finds links to the old paths in your local site and rewrites them in the same style, with undo.

Fixing broken links after a rename in FTP by Zaweba

Renaming a file on a website is easy. Finding every page, stylesheet and script that pointed at the old name is the part that goes wrong, and the result is a broken image here and a missing stylesheet there, noticed days later by a visitor. FTP by Zaweba follows a rename or move in the Disk view with a check of your own site for references to the old paths, and offers to fix them.

What it looks for

After files are renamed or moved on the server, a window lists references to the old paths in the linked local site, that is, the local folder set for that site in Site Manager. It searches .php, .html, .css, .js and .htaccess files, which between them hold almost every link a typical site makes: page links and image tags in HTML and PHP, background images and imports in CSS, file paths in scripts, and redirects or rules in .htaccess.

Each reference is listed so you can see where it is before deciding anything.

Fixing them

Tick the references you want to fix and choose Update references locally. The app rewrites each one in the same style it was written in. A relative link stays relative, a link from the root starting with a slash 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.

That attention to style matters more than it sounds. A tool that rewrote every link as a full address would technically work, but it would change the character of the code and break the moment the site moved to a new domain. Keeping each link in its own style means the fix looks like something you would have written yourself.

Only local files are edited. Nothing is changed on the server at this stage, and the update can be undone. Once you are happy, upload the changed files with Put Newer, Put Recent or a normal Put.

Putting it together

A typical tidy goes like this. In Disk, rename a set of images with bulk rename (perhaps Clean up to give them web-safe names) or move them into a tidier folder. The link window appears, listing the pages and stylesheets that referred to them. Tick them all, update them locally, look over the changes in the editor or with Live Preview, then upload.

If the whole thing turns out to be a bad idea, the Disk operations log can undo the rename or move as a batch, and the local link update can be undone too.

What it cannot see

The search covers your local site files of those kinds. It cannot change links held elsewhere: other websites, search engine results, emails you have sent, or content stored in a database (which is where many content management systems keep their pages). If a site is built that way, a renamed image may still be referred to by its old name inside the database.

It also depends on your local copy being up to date. If someone else has added a page on the server that you have not fetched, its links are not in your local folder to be found. Run Get Recent from Server or Get Newer first if you share the site.

Mistakes to avoid

Do not untick references without a reason. If a link is listed, it points at a path that no longer exists, and leaving it means leaving a broken link.

Do not forget the upload. The fix happens on your PC first, which is the safe order, but until the changed files reach the server the live site still points at the old names.

With those two habits, renaming and reorganising files on a live site in FTP by Zaweba stops being a gamble and becomes ordinary housekeeping.