I have a lighttpd server version 1.4.46+ on Linux which serves file1.xml and file2.xml from htdocs directory as is. There are clients that request these files, each of those send a User-Agent header to the server, which have format MyApp 12345 where 12345 is the client version.
What I need to do is to parse the version number 12345 and serve either file1.xml or file2.xml, depending on client version number. file1.xml needs to be served to clients with version number below 11255 and file2.xml needs to be served to clients with version number 11255 and above, and reverse.
What is the easiest way to do this? Preferably to avoid redirects, and preferably to avoid shell or Perl scripts involved, if possible. Avoiding redirects is at highest priority, while using a script is at lower priority.
Any lighttpd gurus around to help me out please?
I have tried Perl style regular expression match (=~) on $HTTP["useragent"] and setting conditional server.document-root to server_root + "/htdocs/file1" or "/htdocs/file2" that include both files, but failed.
I wanted to try include_shell, but not sure how to pass arguments to the script that could handle the version number and possibly write an include configuration file based on results. I could possibly add if-conditions for version numbers 1-11254 to serve file1.xml but that list of conditions would become very huge, which looks wrong.