简体   繁体   中英

lighttpd URL Redirect - subdirectory to root

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM