Removing .php from urls with lighttpd (clean urls)

一曲冷凌霜 提交于 2020-01-03 05:44:04

问题


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.

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

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

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/ returns 404, I guess its trying to find /.php

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?


回答1:


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

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

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.



来源:https://stackoverflow.com/questions/8610830/removing-php-from-urls-with-lighttpd-clean-urls

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