I have Apache rules for a Web application that look like so:
RewriteEngine On
RewriteRule ^unsubscribe/([-A-z0-9]+)/?(.*)$ /list/unsubscribe.php?id=$1&why=$2 [L,QSA]
RewriteRule ^unsub/([-A-z0-9]+)/?(.*)$ /list/subscribe.php?id=$1&why=$2 [L,QSA]
I've tried:
rewrite ^unsubscribe/([-A-z0-9]+)/?(.*)$ /list/unsubscribe.php?id=$1&why=$2;
Which didn't seem to match and results in a 404.
location /unsubscribe {
rewrite ^/unsubscribe/([-A-z0-9]+)/?(.*)$ /list/unsubscribe.php?id=$1&why=$2 break;
}
Results in serving the file, but without PHP processed http://sg.hackandtell.org/unsubscribe/foo/bar
Perhaps can someone recommend some debug strategies?
I don't have a debug strategy, so I am not 100% sure what nginx is doing. Though I rewrote the rewrite rules like so:
And it works. :)
The nginx Wiki states:
So when using
break
, it will use theserver {...}
-wideroot
directive (I assume you have one) and serve the file statically.You should rather try
last
in yourrewrite
rule, because then the PHP-processing route will match in a second turn and direct the request to PHP.