Monthly Archives: August 2006

How to map URLs with PHP and lighttpd

On a number of occasions I've wanted to map a section of a site hosted with lighttpd onto a single PHP file that could then be used as a controller. Here is how I go about doing it.

The first part is to re-write the given part of the site to the PHP file you want to be the controller. Add the following to your configuration file:

url.rewrite = (
"^/(.*)" => "/controller.php"

You can then start with a simple example to see where you will get your URL information from:

echo $_SERVER&#91;"REQUEST_URI"&#93;;

The $_SERVER["REQUEST_URI"] value will be the requested URI. You can now break it up into multiple parts with explode:

$urlParts = explode("/", $_SERVER&#91;'REQUEST_URI'&#93;);
echo $urlParts&#91;1&#93;;

At this point you have an array of the URI parts and can map those however you want using PHP.

Tags: ,

Limiting Bandwidth Usage on Xen Linux Setup

Xen seems to be gaining speed these days and has a lot of useful features for those who want to resale or otherwise split a single box. Now that you have your Xen system set up you may be interested in going farther with bandwidth limiting.

The hardest part of setting up bandwidth limiting is understanding the traffic control system under Linux. This mainly revolves around the tc command.

Continue reading