1

I have question if it is possible do run mod_rewrite rule when 404 error occurs. Example:

Request: http://domain.com/files/img/file.jpg

If there is no /files/file.jpg, then Lightttpd should rewrite request to file /files2/img/file.jpg

How to do that in lighttpd/mod_rewrite conf?

1 Answer 1

0

You should use mod_magnet and write simple lua script to do this job.

# lua redirect example
# match URI for /files
if (string.match(lighty.env["uri.path"], "^/files")) then
  # test file existence with stat()
  if (not lighty.stat(lighty.env["physical.path"])) then
    lighty.env["physical.path"] = lighty.env["physical.doc-root"] .. "/files2/img/file.jpg"
  end
end

More examples in link above.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .