How to quick and easy remove part of an URL in Nginx with HttpRewriteModule?

Solution 1:

Do you mean something like:

rewrite ^/component(.*)$ $1 last;

Solution 2:

Depending where you define the rewrite directive you have two ways to implement it:

A. In the server context

server {
    ...
    rewrite ^/component(.*)$ $1 last;
    ...
}

B. In the location context

location /component {
    rewrite ^/component(.*)$ $1 break;
}

Teo, why did you change the flag last to break? Because, if this directive is put inside of a location context, the last flag will make nginx to run 10 cycles and return the 500 error.