Lighttpd rewriting files and directories
I'm trying to do url rewriting with Lighttpd. I have what I need partially working. Right now I have this: http://domain.com/name/a/123 which rewrites to http://domain.com/name/a.php?pid=123
I do this with this rewrite-once rule: "^/name/a/([^/]+)"=> "/name/a.ph开发者_JAVA技巧p?pid=$1"
That php page has external resources that are not getting rewritten such as the JavaScript and CSS files. Is there a way I can also have the rewrite do the following?
http://domain.com/name/a/js/file.js => http://domain.com/name/js/file.js
A rewrite rule like the following should do the job. In perl syntax, assuming $str contains http://domain.com/name/a/js/file.js
$str =~ s/\/a\//\//
Extrapolating from the regex syntax given for your partially working regex, in Lighthttpd this should map to
"/a/"=>"/"
What this does is, looks for "/a/" and replaces this by "/". Applying this to your example (http://domain.com/name/a/js/file.js) gives http://domain.com/name/js/file.js
精彩评论