I've recently reduced a site from a huge wordpress blog to a single page (homepage) and one other page.
I'd like to 301 redirect all pages which aren't the homepage or /confirmed
to the homepage. I've tried a few things, but they all end in a redirect loop. Here is what I have in my conf.
Thanks for the help!
location / {
try_files $uri $uri/ $uri/index.php?$args;
}
location /confirmed {
try_files $uri $uri/ /confirm-user.php?$args;
}
With this config, all other urls are going to the homepage, but it's not a 301.
I believe this will do your bidding:
This should do the trick:
First
location
matches the root path and only root path.Second block matches the
/confirmed
and only/confirmed
.Last
location
matches all other URLs, triggering the redirect.Further information can be found in nginx core module documentation