Please convert this mod rewrite rule

Francis Daly francis at
Tue Apr 12 02:50:29 MSD 2011

On Mon, Apr 11, 2011 at 06:15:09PM -0400, alex1950 wrote:

Hi there,

> 	RewriteRule test-(.*)\.htm$ inc/tesmodrewite.php?q=test_$1
> 	RewriteRule test2-(.*)\.htm$ /inc/tesmodrewite.php?q=test_$1
> 	RewriteRule pm-(.*)\.(jpg|png|gif|html)$ index.php?pm=$1

As some starting notes:

* replace "RewriteRule" with "rewrite"
* stick a ";" at the end of the line
* the first character of the request is "/"
* the replacement probably wants to start with "/"
* debug log is your friend

The third note is relevant if your regex starts with "^". None of yours
here do.

For the fourth note, do you want "/a/b/test-c.htm"
to be rewritten to "/inc/tesmodrewite.php?q=test_c" or to
"/a/b/inc/tesmodrewite.php?q=test_c"? (The answer is probably obvious
to one who knows the apache syntax well.) You'll want the leading "/"
either explicitly, or as part of a (new) initial (.*) in the regex and
corresponding $1 in the replacement.

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list