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

ez77 nginx-forum at nginx.us
Mon Sep 13 21:39:05 MSD 2010


> In this configuration:
> 
> rewrite ^(.*/)index.html http://$host$1 permanent;
> 
> location / {
> index index.html;
> }
> 
> nginx will not run the server level rewrite, after the internal
redrect,
> so there will not be the loop.In this configuration:
> 
> rewrite ^(.*/)index.html http://$host$1 permanent;> 
> 
> location / {
> index index.html;
> }
> 
> nginx will not run the server level rewrite, after the internal
redrect,
> so there will not be the loop.

I still get a redirect this way. Let me point out the "mysite"
configuration file under /etc/nginx/sites-available/ (too embarrassed to
give the actual highly-in-construction site):

server {
	listen   mysite:80;
	server_name  .mysite;
        if ($host ~* .\.(mysite.*)) {
                set $host_without_www $1;
                rewrite ^(.*)$ http://$host_without_www$1 permanent;
        }

	access_log  /var/log/nginx/mysite.access.log;

    rewrite ^(.*/)index.html http://$host$1 permanent;

	location / { 
	    root   /var/www/mysite;
	    index  index.html index.htm;
	}
	error_page   500 502 503 504  /50x.html;
	location = /50x.html {
		root   /var/www/mysite;
	}
}

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




More information about the nginx mailing list