lighttpd URL Redirect - subdirectory to root

回眸只為那壹抹淺笑 提交于 2020-01-07 05:23:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!