what if web servers could serve up a static site where custom headers and/or status code can be prepended just like they are in http? like you could set up a redirect by just having the file be (note no version)
HTTP 301
Location: /some/place/else
or set the charset of a text file with
Content-Type: text/plain; charset=Shift_JIS
your text here
rather than using some web-server-specific config format. you would also need a file extension or similar on disk to signal the presence of a “header”, but that can be hidden with rewrite rules.
has anyone done this? i guess it would only make sense if the format was specified in an interoperable way.
oh sick, this exists!! i don’t know if it caught on outside of apache, but mod_asis lets you take any file with (say) .asis extension and treat it as cgi output. that format is already specified in rfc 3875, including a way to optionally set the status. so you can do a redirect by creating some /var/www/foo.asis
with like
Status: 301
Location: /some/place/else
you could even use this to make your own tiny link shortener. currently my solution for this with nginx is a shell script that appends a location rule to a config fragment somewhere like
$ go.sh https://example.com/bar https://go.example.com/i2jc $ tail -1 /etc/nginx/go.conf location = /i2jc { return 303 https://example.com/bar; }
and it has to reload nginx, because it’s a config change. but this would mean the script could just create /var/www/i2jc.asis
as above :)