レンタルサーバーhetemlで共有SSlを使うと、urlがhttps://ssl***.heteml.jp/ユーザーネーム/フォルダ/となり、cakephpをインストールてもcssやimgなどが表示されない。
この場合、app/webroot/index.phpを書き換えることで解決する。
てっく★ゆきろぐ Rev2様に解決法が書いてあるのだが、馬鹿(と書いてボクと読む)にも分かるようにしておく。
以下を61行目から最後までコピペ。(ver1.3.7)
if (!defined('WEBROOT_DIR')) {
define('WEBROOT_DIR', basename(dirname(__FILE__)));
}
if (!defined('WWW_ROOT')) {
define('WWW_ROOT', dirname(__FILE__) . DS);
}
if (!defined('CORE_PATH')) {
if (function_exists('ini_set') && ini_set('include_path', CAKE_CORE_INCLUDE_PATH . PATH_SEPARATOR . ROOT . DS . APP_DIR . DS . PATH_SEPARATOR . ini_get('include_path'))) {
define('APP_PATH', null);
define('CORE_PATH', null);
} else {
define('APP_PATH', ROOT . DS . APP_DIR . DS);
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
}
}
// define img/css/js
define ( "URLBASE" , "/../ユーザー名/フォルダ名/" ) ;
define('IMAGES_URL', URLBASE . 'img/');
define('CSS_URL', URLBASE . 'css/');
define('JS_URL', URLBASE . 'js/');
if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) {
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
}
if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
return;
} else {
$Dispatcher = new Dispatcher();
$Dispatcher->dispatch();
}
これでユーザー名とフォルダ名を書き換えれば、共用SSLでもいける。