使用lighttpd从网址中删除.php(干净的网址) [英] Removing .php from urls with lighttpd (clean urls)

查看:75
本文介绍了使用lighttpd从网址中删除.php(干净的网址)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将过载的服务器从apache2迁移到lighttpd,目前我正在代理lighttpd服务器的所有静态资源,但这仍然不能解决负载问题.

I am migrating an over loaded server from apache2 to lighttpd, currently I am proxying all the static resources from the lighttpd server but that still doesn't fix the load problems.

我想将所有内容迁移到lighttpd,但是遇到了问题.

I want to migrate everything to lighttpd but I've run into a problem.

Apache2具有多视图功能,可以清除lighttpd不能清除的URL.

Apache2 has multiviews functionality to clean up URLs which lighttpd doesn't.

我在lighttpd中找到了以下代码

I found the following code to do it in lighttpd

url.rewrite-if-not-file = ( "^([^?]*)(\?.*)?$" => "$1.php$2" )

它可以工作,但是有两个问题

It works but it has two problems

1:website.com/返回404,我猜想它试图找到/.php

1: website.com/ returns 404, I guess its trying to find /.php

2:website.com/user/Username也返回404(应该找到user.php,然后php脚本通过查看$ _SERVER ['REQUEST_URI']完成其余工作)

2: website.com/user/Username also returns 404 (Its supposed to find user.php, then the php script does the rest by looking at $_SERVER['REQUEST_URI'])

如何重写代码以解决这些问题?

How do I rewrite the code to fix these problems?

推荐答案

我会尽量使用/添加类似内容:

I'd prolly try to use/add something like:

url.rewrite-once = (
 "^/$" => "/",
 "^/users/(.*)" => "/users/user.php"
)

http://redmine.lighttpd.net/wiki/1/Docs:ModRewrite
关于您的负载问题:您可能想阅读有关鱿鱼的信息,除了简单的代理功能外,它还具有缓存功能.

http://redmine.lighttpd.net/wiki/1/Docs:ModRewrite
About your load problems: You might want to read about squid which has caching besides simple proxy features.

这篇关于使用lighttpd从网址中删除.php(干净的网址)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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