NGINX redirection issue

manish-ezest nginx-forum at nginx.us
Thu Aug 7 03:37:42 UTC 2014


Hello All,

I am facing some issue regarding nginx redirection. I want to remove .html
extension from all the html pages and all the index.html pages. For example

1. 
http://www.aaa.com/bbb/ccc.html should show the content of
http://www.aaa.com/bbb/ccc.html but the URL should show
http://www.aaa.com/bbb/ccc

2. http://www.aaa.com/index.html should show the content of
http://www.aaa.com/index.html but the URL should show http://www.aaa.com.

There are few rewrites already there which are given below

1. Whenever you try to access the http://www.aaa.com site, it will redirect
to http://www.aaa.com/aaa/bbb/ccc/ddd/index.html.
 http://www.aaa.com    -----> http://www.aaa.com/aaa/bbb/ccc/ddd/index.html.

2. All directory lookups to 'index.html'
rewrite ^(.*)/$ $1/index.html permanent;
3. All open strings to index.html
rewrite ^(.*)/([^\.\?/]+)$  $1/$2/index.html permanent;

Now whenever I try to implement the change, the site went into a redirect
loop and gives following error in the error log. 

2014/08/05 14:48:03 [error] 10392#0: *750 rewrite or internal redirection
cycle while internally redirecting to "/index.html", client: 1.1.1.1,
server: www.aaa.com, request: "GET /aaa/ccc HTTP/1.1", host: "www.aaa.com"

Please suggest how to solve the issue

--Manish

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



More information about the nginx mailing list