rewrite rule

mike mike503 at gmail.com
Sun Mar 1 22:36:29 MSK 2009


To simplify things you could just point all requests to a single handler.

rewrite  ^/item-(.*).html$ /handler.php?uri=$1;

then handler.php has something like:

$uri = explode('_', filter_input(INPUT_GET, 'uri', FILTER_SANITIZE_STRING));
$_GET['ccid'] = isset($uri[4]) ? $uri[4] : '';
$_GET['country'] = isset($uri[3]) ? $uri[3] : '';
$_GET['item'] = isset($uri[2]) ? $uri[2] : '';
$_GET['auction'] = isset($uri[1]) ? $uri[1] : '';
require 'auction.php';

Something of that nature

Or you could just rewrite auction.php (since it is a single script) to
include the stuff above, and instead of forcing $_GET stuff, just
assign it as $request['country'] $request['item'] etc...

(various ways but simplifies webserver configuration, which requires
administrative duties, reloading the server, if it's a multiple
webserver environment each one needs tweaked, etc) - this keeps it in
the userland and really does not add much overhead at all.

On Sun, Mar 1, 2009 at 5:58 AM, Max <maxbear at gmail.com> wrote:
> Hello,
>
> I tried to change the following apache rewrite to work under nginx. But it's
> still not working.
>
> RewriteEngine On
> RewriteBase /
> RewriteRule ^item-(.*)_(.*)_(.*)_(.*).html$
> auction.php?title=$1&item=$2&country=$3&ccid=$4
> RewriteRule ^item-(.*)_(.*)_(.*).html$
> auction.php?title=$1&item=$2&country=$3
> RewriteRule ^item-(.*)_(.*).html$ auction.php?title=$1&item=$2
>
> Could anyone teach me how can I do it correctly? Thanks a lot.
>
> Max
>





More information about the nginx mailing list