Apache,PHP5,PEAR,MySQL,XAMPP,cakePHPを使ったWebサイト構築のTips cakePHP1.2でモバイルサイトとPCサイトでURL,レイアウトを使い分ける場合の設定方法。 cake1.1系ではwebserviceが使えたが、1.2系では使えなくなっているので、prefixを使用する。 1. URLルーティングでprefixを設定する [app/config/routes.php]に下記を追加する。 Router::connect('/m/:controller/:action', array('prefix' => 'mobile')) "/m/xxx/yyy"へアクセスがなされると、prefix=mobileを有効とする。 2. prefix用アクションを作成する [app/controllers/xxx_controller.php]に下記を追加する。
![[cakePHP1.2]モバイルサイトとPCの切り分け その1](https://cdn-ak-scissors.b.st-hatena.com/image/square/126e9c63960837b5815901e11e1f6c1303c17f2b/height=288;version=1;width=512/https%3A%2F%2Fblog.seesaa.jp%2Fimg%2Fogp_logo.png)