Free

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

How-to

Keeping files off the server with exclusion patterns in FTP by Zaweba

Exclusion patterns in FTP by Zaweba stop files such as logs, caches and node_modules from ever being uploaded or downloaded. Here is how the rules work.

Keeping files off the server with exclusion patterns in FTP by Zaweba

Not every file in a site folder belongs on the server, and not every file on the server belongs on your PC. Build tools leave folders full of packages, servers write logs and caches, and editors leave little files of their own. Each site in FTP by Zaweba has an Exclude box in Site Manager where you list what should never move, one pattern per line. Anything that matches is never transferred, in either direction.

How patterns match

A pattern without a slash matches a name anywhere in the site. node_modules on its own line excludes a folder of that name wherever it sits, at the top or deep inside a theme. *.log excludes every file ending in .log, in any folder.

A pattern with a slash in it matches from the site root instead. cache/** means the cache folder at the top of the site and everything under it, but not a folder called cache somewhere else.

The wildcards behave in a predictable way. * and ? stay within one folder level, so a pattern like images/*.tmp catches files directly in images but not in folders below it. ** spans levels, so it reaches as deep as the tree goes. Matching ignores case, which suits Windows, where Thumbs.db and thumbs.db are the same file.

Blank lines are ignored, and so is any line starting with #. Use # lines as notes to yourself or to whoever takes the site over, such as a line explaining why a folder is left out.

Anything inside an excluded folder is excluded too. You never need a second pattern for its contents.

What it affects

Excluded items are never transferred. That covers single Put and Get, Put All, Put Newer, Put Recent, Get Newer, Get Recent, Get Entire Site and Sync. It is a rule about the site, not about one command, so you set it once and every transfer respects it.

Patterns worth considering

Which patterns you need depends on how you build the site, but a few kinds come up often. Package folders such as node_modules are large and are usually rebuilt rather than copied. Log files, *.log, are written by the server and grow constantly, so downloading them on every sync is wasted time. Cache folders hold generated files the server will make again. Files your own tools create while you work, such as editor backups or system files Windows drops into picture folders, are worth excluding too.

Be more careful with folders like uploads. On many sites, people upload pictures through the website itself, so the server copy is the only copy. Excluding that folder means a Get will never bring those pictures down to your PC, which may or may not be what you want.

Mistakes to avoid

The most common surprise is a pattern that catches more than intended. A short name without a slash matches anywhere, so a pattern meant for one folder can also hide a folder of the same name elsewhere. Add the path from the root, with a slash, when you mean one place only.

The second is forgetting a pattern exists. If a file never seems to upload and no error appears, open Site Manager and read the Exclude box. Put a # note above anything unusual so the reason is not lost.

The third is confusing exclusions with protection. Exclude stops transfers. It is a separate thing from protected paths, which stop important files such as .htaccess and wp-config.php from being moved, renamed or deleted in the Disk view. One keeps files from travelling, the other keeps them from being damaged.

Moving patterns with your sites

Exclusions are part of each site's settings, so Export Site Settings carries them to another PC along with everything else. Set them up carefully once and every copy of FTP by Zaweba you use them on will behave the same way.