Redirect question (inception inside)

I want to redirect /us/us/directory/filename to the
/us/directory/filename directory on my Nginx server.

but this

    if ( $request_filename ~ /us/us/.+ ) {
            rewrite ^(.*) http://mysiteurlt/us/$1 permanent;
    }

wont work.

How can i redirect or rewrite such url ?

Shouldn’t the /us/ be removed in the rewrite? what does the logfile say
where it is trying to locate to?

Posted at Nginx Forum:

On Sat, Aug 16, 2014 at 5:27 PM, Ronald Van A. [email protected]
wrote:

How can i redirect or rewrite such url ?
location ^~ /us/us/ {
rewrite ^/us(/us/.*) $1 permanent;
}

NICE : it works

more complicated one :

/ue//ue/data/filename => /ue/data/filenam
there is 2 / in the URL.

location ^~ /ue//ue/ {
rewrite ^/ue(/ue/.*) $1 permanent;
}

does not work :o(

Le 16 aot 2014 10:52, Edho A. [email protected] a crit :

On Aug 16, 2014 6:22 PM, “Ronald Van A.” [email protected] wrote:

    }

does not work :o(

try reading the documentation: Module ngx_http_core_module

YEP thank you :

The matching is performed against a normalized URI, after decoding the text
encoded in the %XX form, resolving references to relative path components . and
…, and possible compression of two or more adjacent slashes into a single slash.

so i do not have to put // in the location , and it works

location ^~ /ue/ue/ {
rewrite ^/ue(/ue/.*) $1 permanent;
}

Thank you all people here.


Ronald,
Paris.

Le 16 aot 2014 12:07, Edho A. [email protected] a crit :