base_url in settings.php with mobile version I've both www.example.com and m.example.com pointing to the same directory in Ubuntu and there was in the settings.php  with this line:

$base_url="www.example.com";


I want to ask what will happen in this case in Drupal where sites are accessed as www. or the m. versions? 

In the hook_custom_theme I'm returing a mobile theme whenever the URL is starting with "m.".

I was getting some wierd mix up of mobile and the desktop versions. 

I was not able to find any cid with "http://m." URLs in the cache_page mysql table. After I removed this $base_url now  both mobile and the desktop versions seem to be showing fine now and also cache_page table is having rows with cid with "http://m...".

I'm not fully sure this but could $base_url cause this?
How is your /sites folder structure? You can create subdomain m.example.com, and implement the mobile version in there. 

There are different approaches in implementing the subdomains in drupal. it may be multisite and shared database or multisite with different databases and single code and different databases .

what you are looking for is a shared database but different themes (multiple codes), Here is good discussion about this.