I have a Wordpress site using Breeze cache plugin. The theme shows a different design for desktop PCs and a different design for mobile devices (which is good).
But the cache plugin shows the first cached design to both the devices. For example, if mobile device opens a page first, then that design is shown for desktop devices also.
Since there are no additional options in Breeze cache to cache a different version for mobile devices, I came up with an idea to append a querystring to the original URL. Example: http://www.example.com/?m=1
I got an idea from the following link, https://gist.github.com/slav123/7867092 on how to detect mobile devices via htaccess.
I used the following code in the htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# Check if this looks like a mobile device
# (You could add another [OR] to the second one and add in what you
# had to check, but I believe most mobile devices should send at
# least one of these headers)
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP:Profile} !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} "acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "wapp|wapr|webc|winw|winw|xda|xda-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "up.browser|up.link|windowssce|iemobile|mini|mmp" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "symbian|midp|wap|phone|pocket|mobile|pda|psp" [NC]
RewriteCond %{HTTP_USER_AGENT} !macintosh [NC]
# Can not read and write cookie in same request, must duplicate condition
RewriteCond %{QUERY_STRING} !(^|&)m=0(&|$)
# Now add the querystring to the URL and proceed the steps from the beginning
RewriteRule ^ %{REQUEST_URI}?m=1 [N]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I used the [N] flag to proceed. And the URL is getting appended.
But I'm getting a 404 error for all the URLs.
I don't know how to append the query string to the existing URL in Wordpress, using htaccess.
Can someone please help me out on this issue?
Or if there are any other better method, then please do help me.
Thank you. Regards Edward Anil Joseph