Rewrite rule

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

On Sun, Mar 01, 2009 at 09:58:25PM +0800, Max wrote:

Could anyone teach me how can I do it correctly? Thanks a lot.

  location /item- {
       rewrite  ^/item-(.*)_(.*)_(.*)_(.*).html$
                /auction.php?title=$1&item=$2&country=$3&ccid=$4
                last;

       rewrite  ^/item-(.*)_(.*)_(.*).html$
                /auction.php?title=$1&item=$2&country=$3
                last;

       rewrite  ^/item-(.*)_(.*).html$
                /auction.php?title=$1&item=$2
                last;
  }

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.

Thanks a lot for the rewrite rule.

I posted the wrong rewrite rule:-( in my origial post. This is the one
that
I want to change:

RewriteEngine On
RewriteBase /
RewriteRule ^images/e/(.)$ http://thumbs.ebaystatic.com/pict/$1 [R,L]
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 someone help me to make it work? Thanks a lot :-).

Max

Thanks a lot.

Max

Apache:
RewriteRule ^images/e/(.)$ http://thumbs.ebaystatic.com/pict/$1 [R,L]
NginX:
rewrite ^/images/e/(.
)$ http://thumbs.ebaystatic.com/pict/$1
permanent;

If you compare what you sent and what Igor replied with, it should be
pretty
clear that the omitted rule should be very similar. It wouldn’t hurt to
take some time to learn regular expressions, either:
http://www.google.com/search?hl=en&q=learn+regular+expressions+now!&btnG=Search