1

I have a mobile version of a site http://www.m.fdl.de/ and a desktop version http://www.fdl.de/

With a .htaccess redirect I link all mobile users to the mobile version, what is running nice.

On my mobile Site I set a link in the footer that should link back to the desktop version. I tried it with several .htaccess solutions I found on stackoverflow but with no success.

my link is always linking me back to the mobile site.

This is my .htaccess . I found it on this post: Mobile Redirect using htaccess

RewriteEngine on
RewriteBase /
# Check if this is the noredirect query string
RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)
# Set a cookie, and skip the next rule
RewriteRule ^ - [CO=mredir:0:www.fdl.de]

# 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]

# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST}          !^m\.
# Can not read and write cookie in same request, must duplicate condition
RewriteCond %{QUERY_STRING} !(^|&)m=0(&|$) 

# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP_COOKIE}        !^.*mredir=0.*$ [NC]

# Now redirect to the mobile site
RewriteRule ^ http://m.fdl.de [R,L]

It woul be very nice if someon coul help me!

Community
  • 1
  • 1
oBear
  • 41
  • 7
  • duplicate http://stackoverflow.com/questions/8478519/mobile-redirect-with-htaccess-for-jquery-mobile-site?? – Book Of Zeus Dec 13 '11 at 11:36
  • Seems like the script you copied is broken, to begin with. – Gerben Dec 13 '11 at 16:58
  • Try setting the domain of the cookie to `.fdl.de` and changing `RewriteCond %{HTTP_COOKIE} !^.*mredir=0.*$ [NC]` to `RewriteCond %{HTTP_COOKIE} !^.*?mredir=0.*$ [NC]` (make the first catch-all lazy). Those are the only two potential issues I could spot. – Dan Ambrisco Dec 13 '11 at 21:38
  • @Gerben : What do you mean with "broken"? It sends me to the mobile page. So far so good. The link back to the desktop site is not working. That's right. – oBear Dec 16 '11 at 15:27
  • @dambrisco : Thanks for helping. I tried your advise but with no success. :( – oBear Dec 16 '11 at 15:28

1 Answers1

0

I might be really late, but i found out that the link to the full site must be like this:

<a href="http://www.example.com?m=0">Full Site</a>

Hope it helped.

Julian
  • 1