# Rewrite /index.html to /

**URL:** <https://www.ruby-forum.com/t/rewrite-index-html-to/213608>\
**Category:** NGINX\
**Created:** [November 7, 2011, 6:34am UTC](https://www.ruby-forum.com/t/rewrite-index-html-to/213608 "2011-11-07T06:34:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [November 7, 2011, 6:34am UTC](https://www.ruby-forum.com/t/rewrite-index-html-to/213608/1 "2011-11-07T06:34:48Z")

</div>

Developing static files on the local filesystem I use index.html instead  
of / for the home page.  
When I push them to the remote server I want  
[http://domain.com/index.html](http://domain.com/index.html) to be redirected to [http://domain.com/](http://domain.com/) for  
SEO reasons.  
I’ve Googled but the best I seem to be able to achieve is a redirect  
loop. What do I need to do?

Here are my failed rules :

# rewrite ^index.html$ $scheme://domain.com/ permanent;

# rewrite /index.html $scheme://domain.com/ permanent;

# location = /index.html {

# rewrite ^(.\*) $scheme://domain.com/ permanent;

# }

Thanks.

Posted at Nginx Forum:

> **[Rewrite /index.html to /](https://forum.nginx.org/read.php?2,217899,217899#msg-217899)**
>
> Developing static files on the local filesystem I use index.html instead of / for the home page. When I push them to the remote server I want http://domain.com/index.html to be redirected to http://domain.com/ for SEO reasons. I've Googled but the...

---

<div class="post-metadata">

**Author:** ![mark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mark](https://www.ruby-forum.com/u/mark)\
**Post date:** [November 7, 2011, 8:25am UTC](https://www.ruby-forum.com/t/rewrite-index-html-to/213608/2 "2011-11-07T08:25:18Z")

</div>

On Mon, Nov 07, 2011 at 12:34:13AM -0500, Mark wrote:

> # rewrite ^index.html$ $scheme://domain.com/ permanent;
> 
> # rewrite /index.html $scheme://domain.com/ permanent;
> 
> # location = /index.html {
> 
> # rewrite ^(.\*) $scheme://domain.com/ permanent;
> 
> # }
> 
> Thanks.

Either

location = / {  
try\_files /index.html =404;  
}

location = /index.html {  
internal;  
error\_page 404 =301 $scheme://domain.com/;  
}

or

location = / {  
index index.html;  
}

location = /index.html {  
internal;  
error\_page 404 =301 $scheme://domain.com/;  
}

–  
Igor S.

---

<div class="post-metadata">

**Author:** ![mark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mark](https://www.ruby-forum.com/u/mark)\
**Post date:** [November 7, 2011, 12:33pm UTC](https://www.ruby-forum.com/t/rewrite-index-html-to/213608/3 "2011-11-07T12:33:43Z")

</div>

Perfect!

Many thanks.

Спасибо большое.

Posted at Nginx Forum:

> **[Re: Rewrite /index.html to /](https://forum.nginx.org/read.php?2,217899,217915#msg-217915)**
>
> Developing static files on the local filesystem I use index.html instead of / for the home page. When I push them to the remote server I want http://domain.com/index.html to be redirected to http://domain.com/ for SEO reasons. I've Googled but the...
