Dom
Dom

Reputation: 878

Is there a way to have a full site button on a mobile app without javascript?

I currently an redirecting to a mobile site based through htaccess as follows:

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|opera mobile|palmos|webos" [NC]
RewriteRule ^$ http://m.example.com/ [L,R=302]

Is there someway to have a full site button on my mobile version that will ignore this rule if clicked? I don't want to use javascript to do my redirect and check for full site...I'm okay with the idea of php doing it though, but I know htaccess gets knocked off before php rules.

Upvotes: 5

Views: 60

Answers (1)

anubhava
anubhava

Reputation: 784958

You can create a button/href link with this URL:

<a href="/?desktop=1">Full Desktop Site</a>

And then change your rewrite as this:

RewriteEngine On

RewriteCond %{QUERY_STRING} !(^|&)desktop=1(&|$) [NC]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|opera mobile|palmos|webos" [NC]
RewriteRule ^$ http://m.example.com/ [L,R=302]

Upvotes: 2

Related Questions