I have a website that has a mobile version page, and since my website is behind the reverse proxy, I need a conditional function that can decide which version to be shown to visitors. I'm using Apache 2.4, the ProxyPass and ProxyReverse doesn't allowed to be inside of "If - Elseif" statement, so I tried with RewriteCond which is doesn't succeed.
Here is my VirtualHost
<VirtualHost *:80>
ServerName MyWebsite.com
ServerAlias www.ReverseProxy/ ReverseProxy/m/
ProxyPreserveHost On
RewriteEngine On
RequestHeader set "Host" "MyWebsite.com"
#Show mobile version if visitors used mobile device
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|opera mobile|palmos|webos" [NC]
ProxyPass / http://MyWebsite.com:80/m/
ProxyPassReverse / http://MyWebsite.com:80/m/
#Show desktop version if not a mobile device
RewriteCond %{HTTP_USER_AGENT} "!(android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|opera mobile|palmos|webos)" [NC]
ProxyPass / http://MyWebsite.com:80/
ProxyPassReverse / http://MyWebsite.com:80/
</VirtualHost>
With the VirtualHost above, my reverse proxy only shows the mobile version. How to solve this? What do I need to add / change to make it work?