Suppose the value of $request_uri is /a/b/c . The current value of $uri is /index.php . Is this possible to change my $uri to /b/c .
I have tried this, which doesn't seem to be working,
if ($request_uri ~* /a/(.*)/(.*)){
set $uri /$1/$2;
}
But this gives error of duplicate "uri" variable. I also tried,
if ($request_uri ~* /a/(.*)/(.*)){
rewrite ^ /$1/$2 break;
}
But $variables don't seem to store values.
Is there a way out? Thanks.
I managed to do it from here.
It basically needed two rewrites.
rewrite ^ $request_uri;
rewrite /.*/(.*)/(.*) /$1/$2;
The first rewrite modifies uri from /index.php -> /a/b/c
.
The second rewrite modifies uri from /a/b/c -> /b/c
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With