As I mentioned in my previous response, the cause of the hack has been located; it's in geodim's answer.
It was infected with a backdoor Python script running as a fake ntpd process. The redirection is handled by a fake Apache module, mod_auth_form.so, which links to the libcurl library.
I'm almost certain that these fake files were uploaded to my server during the last CWP File Manager breach.
The link geodim provided (
https://frantic-bytes.gr/blog/index.php/post/96/CWP+Something+is+intercepting+bots+and+loading+a+different+page+for+them) contains the steps to verify whether the files are real or fake, and to proceed with terminating the hacker's service and deleting those files.
In my case, the strings check didn't find any suspicious strings within mod_auth_form.so, but it failed the RPM integrity check, resulting in a checksum indicating a fake mod_auth_form.so file.
Similarly, the fake /usr/bin/ntpd file was enormous, many megabytes in size, while the originals are small.
By killing the service, deleting those files, and restarting Apache, the selective redirection disappeared.
