rewrite help please...

Steve Holdoway steve at
Sun Dec 9 06:06:01 UTC 2012

I've got a WP site that also provides landing pages for a number of
other sites. I've set it up as the default server config for that IP,
and that's working fine. However, the requirement I've got is to go to a
specific landing page dependant on domain name. This is how I've gone
about it ( as there are a lot of pages...

map $http_host $page_redirect {

default notset; /link/example1;


location = / {
if ( $page_redirect ~ notset ) {
rewrite ^ /index.php break;
# this one works but rewrites the url.
rewrite ^ $page_redirect redirect;
#try_files $page_redirect $page_redirect/ /index.php?$page_redirect;

So I'm basically only trying to redirect from for
example, but not, and only from
predefined domains.

As the comment says, this does work if I use a rewrite ... redirect; but
the URL then changes to, whereas I
want to see alone.

The try_files comes up with a 404, which is really perplexing... I
expected it to go through the .php block like the others!

Any ideas what I'm doing wrong?


Steve Holdoway BSc(Hons) MIITP
Skype: sholdowa
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 6189 bytes
Desc: not available
URL: <>

More information about the nginx mailing list