Search code examples
phpurl-rewritingkohanakohana-3

Making Kohana based mobile site


I have a website in Kohana Framework which is working fine. Lets say website is www.mainsite.com Now I want to make a mobile version of website on URL www.mainsite.com/mobile. I have copied all files of mainsite and pasted in a folder MOBILE inside Mainsite.

Here I have done path settings in index.php to define application ,system and modules path.

Now when I run www.mainsite.com/mobile , it works good and I land on mobile view homepage. The problem arises with links and urls, i.e. when I click any link , it redirects me to views inside www.mainsite.com rather than redirecting me to views inside www.mainsite.com/mobilesite.

I am new to kohana. The problem is related to routing as route files in both directories is same. I tried making some changes but in vain. I actually want to mount www.mainsite.com/mobilesite as base directory to open mobile views, but it only showing homepage as mobile view and clicking on links take me to desktop views of mainsite.

Some code from route.php goes as:

   $config['_default'] = '/deals/local_deals';  //takes me to homepage of mobile view
   $config['local.html'] = "/deals/local_deals"; 
   $config['local/page/(.*)'] = "/deals/local_deals/$1";
   $config['today-deals.html'] = "/deals/today_deals";
   $config['today-deals/page/(.*)'] = "/deals/today_deals/$1";

   $config['get-aways.html'] = "/deals/get_aways";
   $config['get-aways/page/(.*)'] = "/deals/get_aways/$1";

These are some default routes which I need to change for mobile. I am new with PHP framework and apologise in advance if I am asking something silly. Thanks in advance for any help and suggestions.


Solution

  • Found answer to this.

    The problem was with base url. In .htaccess file of mobile site folder it was RewriteBase /mainsite/ , Now I changed it to RewriteBase /mainsite/mobilesite/.And now its working fine for me.