URL_LFS_REWRITE(8)

πŸ’… URL_LFS_REWRITE(8) β€” bestie edition ✨

okay so this is url_lfs_rewrite, and she's a User Contributed Perl Documentation page, which means a real human Perl person wrote her for us 🫢 she's living her best life in section 8 of the manual, and by the end of this you two are gonna be so acquainted.


✨ NAME ✨

url_lfs_rewrite β€” a URL-rewriter based on local file existence πŸ’–

like, she rewrites URLs, but the whole vibe is "does this file actually exist on my disk?" no file, no rewrite. simple as that, no cap.


πŸ¦‹ SYNOPSIS πŸ¦‹

url_lfs_rewrite [--debug] --local-dir=/var/www/ [options]

that's the shape of her. --debug if you're nosy, --local-dir=/var/www/ is basically the main character argument, and then whatever [options] you feel like sprinkling on top 🌸


πŸŽ€ DESCRIPTION πŸŽ€

So here's the ✨ concept ✨: she takes every incoming request and, if that requested file actually lives inside a local directory, she directs the whole thing over to a local web server that's hosting that directory. local file β†’ local server. match made in heaven πŸ’«

And bestie, she's built different β€” this program uses Squid concurrency support πŸ”₯ she can juggle, she can multitask, she's got main character energy.


πŸ’… OPTIONS πŸ’…

  • --debug β€” writes debug info to stderr. for when you simply must know what's going on inside her head πŸ™ˆ
  • --local-dir β€” the directory path under which the script goes searching for files. this is the one she cares about most, give her a good one πŸ₯°
  • --to-scheme β€” the scheme to use for the redirected URL. Default: http
  • --to-host β€” the domain name to use for the redirected URL. Default: localhost
  • --to-path β€” a URL path to add as a prefix for the redirected URL path. If you set it, it must end with a / πŸ‘‘ Default: use the original URL path.

πŸ’€ KNOWN ISSUES πŸ’€

listen, nobody's perfect, and she's got a few little quirks. not me exposing her like this but you need to know:

  • The --local-dir parameter must end with a '/'. Otherwise no file paths will be found. like, zero. none. she will simply not see them 😭
  • URLs with no filename in the path can match directories on the local filesystem and be wrongly redirected to the local web server. oops πŸ™ˆ
  • Any scheme name accepted by the Perl URL library can be used as the --to-scheme parameter. However only schemes supported by Squid will work. so like, the Perl library said yes but Squid said no πŸ’€
  • URLs containing query-strings are not handled well and will not be rewritten even if the base script or file exists on the local system. yeah. she's not great with those. we don't talk about it 🫠

🌈 CONFIGURATION 🌈

here's the setup, copy-paste-able, exactly as written:

url_rewrite_program /path/to/url_lfs_rewrite --local-dir=\var\www\localhost
url_rewrite_children 20 startup=1 idle=1 concurrency=25
url_rewrite_access deny CONNECT
url_rewrite_access deny to_localhost

so β€” this helper can redirect to any web server, but she only actually does it if there's a file matching the URL path segment sitting in the local filesystem. normal configuration requires a web server running on localhost serving up files from a local disk (eg. \var\www\localhost). configuration of that web server is not covered here β€” that's a whole other episode, bestie 🎬


🧚 AUTHOR 🧚

This program and documentation was written by Amos Jeffries <squid3@treenet.co.nz> β€” icon, legend, the moment πŸ‘‘

Based on prior work in rredir.pl by Peter Eisenhauer <pe@pipetronix.de>. First Version: 26. May 1997 ⭐ genuinely vintage, we stan a long-running project.


* Copyright (C) 1996-2026 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
* Please see the COPYING and CONTRIBUTORS files for details.

like, respect the license bestie, it's literally right there 🫢


πŸ“ REPORTING BUGS πŸ“

  • Bug reports need to be made in English. See https://wiki.squid-cache.org/SquidFaq/BugReporting for details of what you need to include with your bug report.
  • Report bugs or bug fixes using https://bugs.squid-cache.org/
  • Report serious security bugs to Squid Bugs <squid-bugs@lists.squid-cache.org>
  • Report ideas for new improvements to the Squid Developers mailing list <squid-dev@lists.squid-cache.org>
fr fr, if it's a security thing, use the security address. don't just drop it in the public tracker, that's not the vibe πŸ™

πŸ”₯ SEE ALSO πŸ”₯

iykyk, go read the squid page next, she's the whole ecosystem 🌸


πŸ’œ and that's the page!! cute little sign-off for you: this one's shipped as part of perl v5.42.2, dated 2026-08-25 β€” so she's fresh, she's current, she's serving. periodt βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from