lighttpd URL重定向-子目录到根目录 [英] lighttpd URL Redirect - subdirectory to root

查看:473
本文介绍了lighttpd URL重定向-子目录到根目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个lighttpd设置,其结构类似于

I have a lighttpd setup with a structure along the lines of

/var/www
/var//www/php
/var/www/icons

图标曾经是php文件夹中的一个文件夹,但是我将其移动了,以使同步文件夹内容的工作更加轻松-因为icons文件夹的内容并不经常更改.但是,这给我留下了CSS标记和JavaScript代码中的大量引用,这些引用可以在/var/www/php/icons上查找图像.我玩过url.redirect

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")

但是据我所知,它什么也没做.当我在浏览器中访问有问题的页面时,仍然收到针对/var/www/php/icons的HTTP 404报告.

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")

此正则表达式将匹配完整路径,并捕获组中的文件名,然后可以使用$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.

这篇关于lighttpd URL重定向-子目录到根目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆