I have a site that checks the user-agent string and if it changes between pages the user is logged out.
Unfortunately I have a problem where Safari is giving a very slightly different string from one page to the next. This seems only to be happening when I am using a redirect with htaccess though.
90.91.993.92 - - [13/Aug/2021:13:37:41 +0100] "GET /admin/ HTTP/1.1" 200 703 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Safari/605.1.15"
90.91.993.92 - - [13/Aug/2021:13:37:42 +0100] "GET /controller/ HTTP/1.1" 200 1571 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15"
90.91.993.92 - - [13/Aug/2021:13:37:42 +0100] "GET /controller/js/controller.js HTTP/1.1" 200 1152 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Safari/605.1.15"
The part that is changing is the version number, on the first page it is Version/14.1.2 but after the redirect it is Version/14.1.1 although notably even requests from the second page (like the JS file) are using Version/14.1.2!
The re-write rule looks like:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/?([^/]*)/?([^/]*)/?([^/]*)/?$ /controller/?&a=$1&b=$2&c=$3&d=$4 [QSA,L]
So where is Version/14.1.1 and how can htaccess be causing this? Is there a safer way to compare the user agent strings?