Warning: Table './internetbusiness/url_alias' is marked as crashed and last (automatic?) repair failed query: SELECT COUNT(pid) FROM url_alias in /home/content/e/r/a/erahbee/html/includes/database.mysqli.inc on line 134
htaccess Lines for Single Drupal Site and Mobile Sub-Domain | Internet Business

Mobile Full Site Switcher

Powered by Drupal, an open source content management system
user warning: Table './internetbusiness/url_alias' is marked as crashed and last (automatic?) repair failed query: SELECT dst FROM url_alias WHERE dst = 'node/11766' in /home/content/e/r/a/erahbee/html/sites/all/modules/globalredirect/globalredirect.module on line 138.

Internet Business

htaccess Lines for Single Drupal Site and Mobile Sub-Domain

Add the lines below to your htaccess file before the “Boost” section. You can find the same code in the .txt document that is attached to this page.

These lines are applicable for a single-site (non-multi-site) set-up and a mobile sub-domain.

Replace “example.com” with your domain name.

Make sure that you have read the introduction and step-by-step tutorial before adding these lines to your htaccess file.

 

Click here for the htaccess lines for a multi-site situation.

 

This code is for 99% based on what I found here: Making a Boost Cached Site Mobile.

The adaptations I have made is mainly adding left and right a $-sign and an extra line to make sure that www.example.com/xyz redirects to m.example.com/xyz and vice versa.

 
 

The Extra htaccess Lines for Drupal Mobile Site

 

 #Replace example.com with your domain
 #Extra htaccess lines for mobile site for www.example.com as single-site configuration
 
 #set cookie (in the client's browser)
 RewriteCond %{QUERY_STRING} ^(.*)device=desktop(.*)$
 RewriteCond %{QUERY_STRING} !^(.*)device=mobile(.*)$
 RewriteRule .* - [CO=mt_device:desktop:.example.com:1440:/]
 
 #redirect to desktop site based on url or cookie
 # don't apply the rules if already in the desktop site, infinitive loop
 RewriteCond %{HTTP_HOST} !^www\.(.*)$
 RewriteCond %{HTTP_HOST} ^m\.example\.com$ [NC]
 RewriteCond %{QUERY_STRING} ^(.*)device=desktop(.*)$ [OR]
 RewriteCond %{HTTP_COOKIE} mt_device=desktop
 RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=302]
 
 #no redirect to mobile when cookie=desktop and user agent is mobile
 RewriteCond %{HTTP_HOST} !^m\.(.*)$
 RewriteCond %{QUERY_STRING} !^(.*)device=mobile(.*)$
 RewriteCond %{HTTP_COOKIE} mt_device=desktop
 #skip the next two rules
 RewriteRule .* - [S=2]
 
 #set cookie (in the client's browser)
 RewriteCond %{QUERY_STRING} ^(.*)device=mobile(.*)$
 RewriteCond %{QUERY_STRING} !^(.*)device=desktop(.*)$
 RewriteRule .* - [CO=mt_device:mobile:.example.com:1440:/]
 
 #redirect to mobile site based on url, cookie or device type
 # don't apply the rules if already in the mobile site, infintine loop
 RewriteCond %{HTTP_HOST} !^m\.(.*)$
 RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
 RewriteCond %{QUERY_STRING} !^(.*)device=desktop(.*)$
 RewriteCond %{QUERY_STRING} ^(.*)device=mobile(.*)$ [OR]
 RewriteCond %{HTTP_COOKIE} mt_device=mobile [OR]
 RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipad|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC,OR]
 RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC,OR]
 RewriteCond %{HTTP_USER_AGENT} "sony|symbian|nokia|samsung|mobile|windows ce|epoc|opera mini" [NC,OR]
 RewriteCond %{HTTP_USER_AGENT} "mini|nitro|j2me|midp-|cldc-|netfront|mot|up\.browser|up\.link|audiovox"[NC,OR]
 RewriteCond %{HTTP_USER_AGENT} "blackberry|ericsson,|panasonic|philips|sanyo|sharp|sie-"[NC,OR]
 RewriteCond %{HTTP_USER_AGENT} "portalmmm|blazer|avantgo|danger|palm|series60|palmsource|pocketpc"[NC,OR]
 RewriteCond %{HTTP_USER_AGENT} "smartphone|rover|ipaq|au-mic,|alcatel|ericy|vodafone\/|wap1\.|wap2\.|iPhone|android"[NC]
 #iPad user agent has "Mobile", but we treat it as desktop
 RewriteCond %{HTTP_USER_AGENT} !ipad [NC]
 #status code 301 would stop future switching between desktop/mobile bcs. browsers cache that status code
 RewriteRule ^(.*)$ http://m.example.com/$1 [L,R=302]
 
 
AttachmentSize
extrahtaccesscodedrupalmobilesite.txt2.79 KB

Recent comments

User login

Navigation