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
Even after changing index, the old page shows – many students think the config isn't working. This happens because of the browser cache. Check with curl or in a private browser window, or press Ctrl+F5.
Ravindra Bagale's Tip – मराठी
index बदलल्यावरही जुनं page दिसतं – बऱ्याच students ना वाटतं config चालत नाही. Browser cache मुळे असं होतं. curl ने किंवा browser च्या private window मध्ये check करा, Ctrl+F5 द्या.
Ravindra Bagale's Tip – हिंदी
index बदलने के बाद भी पुराना page दिखता है – बहुत से students को लगता है config काम नहीं कर रहा. यह browser cache की वजह से होता है. curl से या browser की private window में check करो, Ctrl+F5 दबाओ.
Practice task
Make home.html the first index page on both Nginx and Apache, then remove it and confirm index.html is served again.