Report this

What is the reason for this report?

Remove index.html from URL

Posted on May 3, 2015

Hello,

I’m setting up a new site with nginx and stumbled upon a problem with the url on the frontpage. When I go into my site (for example) http://domain.com then it opens http://domain.com/index.

I would like to remove index and only have it at http://domain.com.

I have successfully removed .html extension on pages (domain.com/aboutus.html -> domain.com/aboutus) but can’t figure out how I can go from (domain.com/index -> domain.com)

This is how my server is configured:

server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/html;

# Make site accessible from http://localhost/
  server_name domain.com;
 
rewrite ^(/.+)\.html$ $scheme://$host$1 permanent;

location / {
	index  index.html;
	try_files $uri.html $uri $uri/ @handler;
	autoindex on;
}

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.