See how different servers handle serving HTML files and trailing slashes.
The format follows https://github.com/slorber/trailing-slash-guide.
Check out my blog to learn more about trailing slashes! https://bjornlu.com/blog/trailing-slash-for-frameworks
website
├── file.html
│
├── folder
│ └── index.html
│
├── both.html
└── both
└── index.html
| Server | Settings | Url | /file | /file/ | /file.html | /folder | /folder/ | /folder/index.html | /both | /both/ | /both.html | /both/index.html |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| express | link | 💢 404 | 💢 404 | ✅ | ➡️ /folder/ | ✅ | ✅ | ➡️ /both/ | ✅ | ✅ | ✅ | |
| express with HTML extensions | link | ✅ | 💢 404 | ✅ | ➡️ /folder/ | ✅ | ✅ | ➡️ /both/ | ✅ | ✅ | ✅ | |
| sirv | link | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
| http-server | link | ✅ | 💢 404 | ✅ | ➡️ /folder/ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
| deno (file-server) | link | 💢 404 | 💢 404 | ✅ | ➡️ /folder/ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
| python -m http.server | link | 💢 404 | 💢 404 | ✅ | ➡️ /folder/ | ✅ | ✅ | ➡️ /both/ | ✅ | ✅ | ✅ | |
| httpd (apache) | link | 💢 404 | 💢 404 | ✅ | ➡️ /folder/ | ✅ | ✅ | ➡️ /both/ | ✅ | ✅ | ✅ | |
| nginx | link | 💢 404 | 💢 404 | ✅ | ➡️ /folder/ | ✅ | ✅ | ➡️ /both/ | ✅ | ✅ | ✅ |
Environments:
- Node: 18.20.3
- Deno: 1.46.3
- Python: 3.12.6
- Apache: 2.4.62
- Nginx: 1.27.1
Here are some configurations I used for my own machine locally. Yours may be different.
/opt/homebrew/etc/httpd/httpd.conf:
ServerName http://localhost:8080
/opt/homebrew/etc/nginx/nginx.conf:
http {
server {
listen 8081;
server_name localhost;
location / {
root /Users/bjorn/Work/oss/trailing-slash-servers/website;
}
}
}
MIT