Can these rules be ported easily to nginx?


#1

I’m considering migrating an ecommerce site that we run, to nginx.

The default rules that we have in Apache, look fairly complex and I’d
like to seek some guidance to see if they can be migrated to Ngix 0.7.27
or somewhere close to that.

  1. RedirectMatch gone:

block all smarty templates (no reason to have these exposed)

RedirectMatch gone ^/.*.tpl$

  1. Complex RewriteRules. These just work under Apache and while I’ve had
    sucess in several instances with nginx by replacing RewriteRule with
    rewrite and the [QSA,L] with last, I’d like to see if anyone spots
    anything obvious.

RewriteRule
^([^/]/)?[^/]±printable-(productcode|title|price|orderby)-up-c-([0-9]+)-p-([0-9]+).html$
$1home.php?printable=Y&sort=$2&sort_direction=0&cat=$3&page=$4 [QSA,L]
RewriteRule
^([^/]
/)?[^/]±printable-(productcode|title|price|orderby)-down-c-([0-9]+)-p-([0-9]+).html$
$1home.php?printable=Y&sort=$2&sort_direction=1&cat=$3&page=$4 [QSA,L]

Regards,
Shri


#2

Shri @ DevLib.Org wrote:

I’m considering migrating an ecommerce site that we run, to nginx.

The default rules that we have in Apache, look fairly complex and I’d
like to seek some guidance to see if they can be migrated to Ngix 0.7.27
or somewhere close to that.

  1. RedirectMatch gone:

block all smarty templates (no reason to have these exposed)

RedirectMatch gone ^/.*.tpl$

This sounds like a location block with a custom status

$1home.php?printable=Y&sort=$2&sort_direction=1&cat=$3&page=$4 [QSA,L]
The rules are not complex; just the regex is :slight_smile:
Read it as:
some_regex new_url [QSA,L]

QSA always happens in nginx.
L corresponds to last
http://wiki.codemongers.com/NginxHttpRewriteModule#rewrite