lighttpd URL重定向

编程入门 行业动态 更新时间:2024-10-19 04:28:15
本文介绍了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重定向

本文发布于:2023-11-01 02:07:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1547935.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   lighttpd   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!