问题
I have a lighttpd setup with a structure along the lines of
/var/www
/var//www/php
/var/www/icons
Icons used to be a folder inside the php folder but I moved it to make the job of synchronizing folder contents easier - since the icons folder contents do not change very often. However, this has left me with a legacy of references in CSS markup and JavaScript code that seek out images at /var/www/php/icons. I have played around with url.redirect
url.redirect = ("/var/www/php/icons" => "/var/www/icons")
but as far as I can see that does nothing at all. When I visit the offending page in my browser I still get an HTTP 404 being reported for /var/www/php/icons.
I imagine I am missing something or am writing the redirect rule incorrectly but I have not been able to figure out something that actually works. I'd much appreciate any help
回答1:
You have to write your redirects for complete paths, not just directories. In your case, it would be:
url.redirect = ("/var/www/php/icons/(.*)" => "/var/www/icons/$1")
This regex will match complete paths and catch the filename in the group which we can then place into the redirect using the $1
.
*Disclaimer: I didn't test this, maybe my syntax is bad, but matching the complete path is necessary.
来源:https://stackoverflow.com/questions/24627185/lighttpd-url-redirect-subdirectory-to-root