Beginner's question: redirecting /dir/index.html to /dir/

ez77 nginx-forum at nginx.us
Sun Sep 12 05:39:36 MSD 2010


> At the risk of pushing it... is there a way to make the redirect 301
rather than 302?

In case anybody is interested, the following code (very similar to the
original I found elsewhere) works OK in the latest version, 0.8.50, with
a 301 response:

      location / {
            root   /var/www/mysite;
            index  index.html index.htm;
            if ($request_uri ~ (.*/)index.html) {
            set $files $1;
            rewrite ^ http://$host$files permanent;
            }
        }

        
By now I don't even know if I tried this exactly with an older
version... certainly something like this, but it didn't work.

Cheers!

Ezequiel

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,128951,129630#msg-129630




More information about the nginx mailing list