I’m running Cloudflare Pro with APO.
Is it possible to run any Wordpress functions at the edge?
I’d like to be able to redirect certain user agents that land on posts with certain taxonomies.
My example:
/**
* Redirect user-agent when using taxonomy redirect
*/
add_action( 'template_redirect', 'device_redirect' );
function device_redirect(){
if (has_term('redirect','manage') &&
(strpos($_SERVER['HTTP_USER_AGENT'], "bot-1") !== false
|| strpos($_SERVER['HTTP_USER_AGENT'], "bot-2") !== false
|| strpos($_SERVER['HTTP_USER_AGENT'], "bot-3") !== false)) {
wp_redirect( 'https://domain.com', 301);
}
}
The above works without Cloudflare, I’d just love to be able to use it with Cloudflare.
Thanks for any insight!