Apparently the below will not work due to nginx locations not allowing negative matching. (See: https://stackoverflow.com/a/16304073/398519 )
Ok if switching the setup is not an option than you will need a location, something like:
location !~* \.php$ {
rewrite /([a-z1-9]+)$ /page1.php?h=$1 last;
}
I believe (not tested) that it should not match .php
or any other item with a .ext
and should only pull from the webroot portion. I am not able to test it at this time unfortunately.
For starters your initial rule is too vague. You need something to distinguish whats goes to page 1 and what goes to page 2.
Such as: http://www.domain.com/p1/xxxxxxx
That way you can parse at the p1 / p2 etc and know how to handle it. For completeness, here are some example rules:
rewrite /p1/([a-z1-9]+)$ /page1.php?h=$1 last;
rewrite /p2/([a-z1-9]+)$ /page2.php?h=$1 last;
If you want to use your original rule, then you need to add a file check and or change the regex to not match .php
or .whatever
I am not sure how to do this on nginx other than creating a location
section before the root location so it gets trapped there first.