Welcome! Log In Create A New Profile

Advanced

rewrite help pleae...

Posted by GreenGecko 
rewrite help pleae...
December 04, 2012 11:43PM
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
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 163
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready