http-redirectnginxpermanent

Nginx 301 Redirect


I have website with permalink like this this:

_http://www.domain.com/read/o/one-url-posting/

_http://www.domain.com/read/t/two-url-posting/

_http://www.domain.com/read/f/four-url-posting/

_http://www.domain.com/read/s/six-url-posting/

_http://www.domain.com/read/n/nine-url-posting/

_http://www.domain.com/read/x/xxx-url-posting/

How to redirect all permalink to _http://www.domain.com/read/nine-url-posting/ without one char between slash after "read" slug?

Thanks


Solution

  • I found answer from another web, like this.

    location ~ ^/read/(.*)/(.*)/ {    
        return 301 /read/$2/;    
    }
    

    Case closed. Thanks