Ravindra BagaleCourses & study guides

8. Hosting a Static Website and Changing the Configuration

8.8 Changing the Index Page

Folder chi URL (/) maagitli ki server konti file dakhvto te index (Nginx) kiwa DirectoryIndex (Apache) tharavto. Kram mahatvacha – pahili sapadleli file vaparli jaate.

# Nginx – inside the server block
index home.html index.html;          # try home.html first, then index.html
# Apache – inside VirtualHost or <Directory>
DirectoryIndex home.html index.html
echo '<h1>Welcome – home.html</h1>' | sudo tee /var/www/mysite/home.html
sudo nginx -t && sudo service nginx reload                 # Nginx
sudo apachectl configtest && sudo service httpd reload     # Apache on Amazon Linux
sudo apache2ctl configtest && sudo service apache2 reload  # Apache on Ubuntu
curl -s http://localhost | head -3

Why this matters for security

If no index file matches and listing is on (autoindex on / Options +Indexes), the server shows every file in the folder. Keep autoindex off and Options -Indexes so a missing index gives 403 instead of a file list.

Ravindra Bagale's Tip

index badallyavar pan juna page disto – khup students la vatte config chalat nahi. Browser cache mule asa hota. curl ne kiwa browser chya private window madhe check kara, Ctrl+F5 dya.

Practice task

Make home.html the first index page on both Nginx and Apache, then remove it and confirm index.html is served again.