svenstaro / miniserve

🌟 For when you really just want to serve some files over HTTP right now!
MIT License
5.95k stars 289 forks source link

Feature request: Redirect support #1437

Closed adrianrudnik closed 1 month ago

adrianrudnik commented 2 months ago

I am currently using miniserve to host a simple, static, multilingual website without any scripts. The one feature I'm really missing is redirect file support with Accept-Language handling. Is this something you could see within the scope of this server?

Idea would be a simple .redirect file in the root that is read on startup. Example content could be

/permalink/pp de /de/datenschutz/ 302
/permalink/pp * /en/privacy-policy/ 301

Not sure if you see a benefit in this, so I wanted to ask. In a prototype I'm currently building, I'm facing the problem of providing a link to legal documents that can be in multiple languages, and I can only define a single link that spans all languages. I could also see some benefit later for hard redirects of outdated content pages, and before diving into another convoluted nginx setup, I thought about this project.

Not much I can provide in terms of Rust code as its not my main language, but I would support the idea with a 50€ one-time sponsor.

svenstaro commented 2 months ago

I'm not sure how I feel about this. Especially the file-based redirects might get really confusing. Also might be a security problem if people upload those files. I guess you could filter it but it's just more stuff to keep in mind. I don't really want miniserve to be a fully-featured webserver.

Chances are, people that need redirects also need to run logic for those redirects and that'll slide us right down the slippery feature creep slope. For instance, in your case I'd probably go for Caddy.

Thoughts?

adrianrudnik commented 1 month ago

Thats fine! I'll go with Caddy or something similar for now, the upload topic could introduce new problems, yes.