问题描述:

How does the lighttpd rewrite work for folowing?

http://example.com/file_46634643.jpg to http://sub.domain.com/46634643.jpg

If it's possible...

网友答案:

Yes, it is possible. Use mod_rewrite, here is an example:

url.rewrite-once = ("^/file_([0-9]+\.jpg)$" => "/$1")

Check Lighttpd's mod_rewrite documentation for more details.

网友答案:

I don't think mod_rewrite allows you to "rewrite" to another (sub)domain. You could use mod_redirect (but it's a redirect, not a rewrite). Here is a slightly modified version of Bartosz's answer:

$HTTP["host"] == "example.com" {
  url.redirect = ( "^/file_([0-9]+\.jpg)$" => "http://sub.domain.com/$1" )
}

Check http://redmine.lighttpd.net/wiki/lighttpd/Docs:ModRedirect

相关阅读:
Top