rewrite help please...
Steve Holdoway
steve at greengecko.co.nz
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 {
hostnames;
default notset;
.example1.com /link/example1;
...
}
hostname example.com;
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 http://www.example.com for
example, but not http://www.example.com/index.php, and only from
predefined domains.
As the comment says, this does work if I use a rewrite ... redirect; but
the URL then changes to http://www.example1.com/link/example1, whereas I
want to see http://www.example1.com 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?
Cheers,
Steve
--
Steve Holdoway BSc(Hons) MIITP
http://www.greengecko.co.nz
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: <http://mailman.nginx.org/pipermail/nginx/attachments/20121209/9bad9361/attachment.bin>
More information about the nginx
mailing list