Hi all,
I'm a bit new to nginx, and I haven't been able to find documentation about this precise problem I've been having, apologize if this has already been covered:
I set up a static mirror of a Wordpress blog on nginx, but some of the old urls end up looking like "/?p=100" instead of their "pretty" permalinks. So I need to permanently redirect "/index.html?p=100" or "/?p=100" to "/2014/04/blog-post-one-hundred/" so that the old links work.
Since there are only about 150 such URLs, I figured I could make a map to handle this problem, but it's not working and I suspect it has to do with nginx's feelings about query strings and regexes.
How should I go about doing this? I was trying stuff like
map $uri $new {
'/?p=100' '/2014/04/blog-post-one-hundred/';
}
if ($arg_p) {
rewrite ^ $new
}
but obviously that hasn't worked (I see "the rewritten URI has a zero length" in the logs). Any ideas?
I'm a bit new to nginx, and I haven't been able to find documentation about this precise problem I've been having, apologize if this has already been covered:
I set up a static mirror of a Wordpress blog on nginx, but some of the old urls end up looking like "/?p=100" instead of their "pretty" permalinks. So I need to permanently redirect "/index.html?p=100" or "/?p=100" to "/2014/04/blog-post-one-hundred/" so that the old links work.
Since there are only about 150 such URLs, I figured I could make a map to handle this problem, but it's not working and I suspect it has to do with nginx's feelings about query strings and regexes.
How should I go about doing this? I was trying stuff like
map $uri $new {
'/?p=100' '/2014/04/blog-post-one-hundred/';
}
if ($arg_p) {
rewrite ^ $new
}
but obviously that hasn't worked (I see "the rewritten URI has a zero length" in the logs). Any ideas?