I have a WordPress blog, and I'd like to redirect all requests to one certain post/page, excluding js, css (and images).
so example.com/some-post/ must redirect (temporarily) to exmaple.com/catch-all/
I was playing around with this, but doesn't quite seem to work (I'm not sure I need to use $uri):
if ($uri !~ \.css$) {
set $redi C;
}
if ($uri !~ \.js$) {
set $redi "($redi)J";
}
if ($uri !~ /catch-all/$) {
set $redi "($redi)P";
}
if ($redi = CJP) {
rewrite ^(.*)$ https://example.com/catch-all/ last;
return 302;
}
if ($uri
- uselocation
negative look behind
. BTW do you really need!= /catch-all/$
?