I have a WordPress website (abetterworldbydesign.com) which has user-agent detection to redirect mobile websites to a subdirectory. It is using the plugin: WPtap Mobile Detector
I want to include a toggle link to switch between the mobile and desktop version. How can I make the site remember that a mobile user has switched to the desktop version and avoid redirecting that user to the mobile version again?
Checking the HTTP_REFERRER is the easiest method - no cookies & just one check.
If the referrer is on your domain - then don't redirect.
A session will probably be the easiest, or still detect mobile, but have a ?mobile=false attached the URL that prevents the user from being redirected, but allows them to easily get back to the mobile site.
Related
I have two different codeigniter CMS for desktop and mobile versions of site. I use codeigniter user agent to detect mobile and redirect to mobile version. I have a link in mobile site to browse the desktop version as well. I used session and cookie separately, one by one in mobile cms and tried to get those values in desktop cms but it was different cms so not possible. How can I switch from mobile to desktop condition there codeigniter user agent is also enabled.
Any help appreciated
Assuming that the two sites are under the same domain ( eg www.site.com and mobile.site.com ), you can have cookies that are available for both, by specifying their domain with a leading period ( ie .site.com ).
That way you can access the cookies from both sites, and if your cookies are the session cookies, you can have a common session as well.
For CodeIgniter, you can use the setting :
$config['cookie_domain'] = ".site.com";
Lets say i have a incoming website request with a url of desktop version
of website.
I'd like to detect if this website has a mobile version.
According to this answer Fetch website mobile version? most of what i have to do is to set User Agent to some mobile phone and server will serve the mobile version.
I think i could also check m.domain.com and mobile.domain.com.
But here's question:
How would i know if server responded with mobile version?
Are there other ways of getting mobile version?
I don't believe there is a one size fits all answer to your question. You could use curl to hit the domain with a couple different user agents and see if different content is returned for mobile vs desktop, or see if you are redirected for either.
I have a PHP based web application and want to be able to offer mobile users the option to view the content of my site through a dedicated set of 'mobile friendly' pages. The URL structure for the mobile site is different to the desktop site.
The idea is that the first time a mobile user hits the index page, a regexp checks the user agent and if they are a mobile device they are given the option to select to view either the desktop or mobile version of the site.
The problem is that I am caching static HTML with my CDN provider (Cotendo). This means that when the cache is populated the mobile user is likely to see a cached version of the desktop site and bypassing the mobile/desktop option page. It also means that with an empty cache, a mobile user could force the CDN to store the cached version of the mobile/desktop option page!
One option would be to check the user agent at the CDN level and bypass cache retrieval for mobile users. However, a signification proportion of traffic to the site is driven by mobile users and serving non-cached content to mobile users is not currently an option.
At the CDN level, can you add a ?mobileoption querystring for mobile devices. Then only show the mobile/desktop option page when that querystring is present.
I have a PHP page (which is displayed through a mobile/android browser) - however, when accessing a link to an external site - it automatically redirects to the mobile version.
I want the link to take user to the desktop version of the webpage even when accessed through a mobile browser.
Is there a way i can specify useragent/or any other setting in my PHP page code to acheive this? Thanks.
Spoofing the user agent string will be a challenge, as it requires you to control the behavior of the browser. You might be able to do it with JavaScript or something, but I doubt it.
If it's just one site, you may wish to take a look at how they're handling redirection of mobile devices. Often, sites will provide mechanisms for overriding the redirect script.
For example, sites using the UC Mobile Web Framework (http://mwf.ucla.edu/) allows you to override their redirect script with a query string parameter. The UCSF Library (http://library.ucsf.edu/) is using that framework for mobile redirects. If you are on a mobile device and go to http://library.ucsf.edu/ then you will be redirected to the mobile version of the site. However, if you go to http://library.ucsf.edu/?ovrrdr=1 then you will get the desktop version.
What you are describing, no. You do not have control of an external site therefore you cannot control what is being served.
I want to develop the mobile (also includes iphone,ipad,andriod) version of my original site. But I don't want to create another sub domain like www.m.mydomain.com, can i dynamically change the document root separately for mobile version and the existing one?
I have also noticed that, when I open facebook form iphone or any andriod mobile it opens with it's original domain name like http://www.facebook.com/ bt when i open it from any other mobile like nokia or samsung it comes with http://m.facebook.com/, what is the difference between this 2?
When it comes to iPhone and Android deveices, a website needs very little adjustments because their web browsering capabilities are really good.
For other devices where the web browsing user experience is less satisfying, the site would dynamically switch them to an alternate and less "intense" version of the website.
As for the m.domain.com feature, this is just a subdomain of the domain.com website. Obviously, it represents a mobile version of the main site and will strip out things like flash and javascript basically anything which will be too much for a basic mobile browser.
The dynamic switching of browsers is done via code. There are ways of detecting what browser just requested your website. Based on the information returned you can then redirect to specific scripts which will handle the user requests from then on.
As an example, you can use this standard argument to check the browsers visiting your site:
$_SERVER['HTTP_USER_AGENT']
Hope that helped.
You can differentiate it by User-Agent property either on Apache level, or PHP level. Though that will not be guaranteed because UA can be spoofed. (But how many mobile users would do UA spoofing to pretend they're not mobile?)
you could possibly use some solution:
create a specific mobile website and put it on folder/subdomain and redirect any user with mobile to that site, example: mydomain.com/m/ or m.mydomain.com
example on redirection:
http://detectmobilebrowsers.mobi/
http://mobiforge.com/developing/story/lightweight-device-detection-php
or
you could use responsive webdesign technique, some framework already available for this
http://csswizardry.com/inuitcss/
http://www.columnal.com/
http://stuffandnonsense.co.uk/projects/320andup/
The difference is that high end mobile devices like iphone/android have enough support and functionality to support the original version of the website (zooming/javascript etc). Other devices are better served an basic website developed for mobile devices with a limited display and/or support.
You do want an special URL for your mobile website - as you'd like your mobile website to correctly appear in the mobile search of search engines.
www is actually also a subdomain, but it is so often used, people do not usually realize it, Usually most browsers add it by default and this is why most servers have it enabled by default.
The case you pointed out is also of subdomains. The server check your HTTP request's user-agent and redirects you to the mobile subdomain appropriately.
This isn't really a quick solution for you, but I highly recommend reading Ethan Marcotte's Responsive Web Design articles on alistapart.org. He goes over the philosophy as well as the practical steps to make a site work well for different contexts - desktop browser to mobile device, etc. There are several articles on the site (just search for responsive web design you'll get several of his articles in your results.)