Apache 利用 mod_rewrite 做到網址轉換達成SEO優化 我們達成了 SEO 的優化,但當刷新頁面很多次時卻有時會出現空白的頁面,將 php 程式段的偵錯模式打開 error_reporting(E_ALL); 會出現下列的錯誤訊息。

Fatal error: Uncaught --> Smarty: unable to write file /xampp/htdocs/myweb/smarty/templates_c\8c6924ac7efe8f944a5a8a181c85433787f58f0c.file.home_index.html.cache.php <-- thrown in D:\xampp\htdocs\myweb\includes\smarty\libs\sysplugins\smarty_internal_write_file.php on line 74

 

此原因是因為同時要寫入 cache file: home_index.html.cache.php 時發生了 lock 的事件。為避免這種情形發生,可以將 Smarty 的設定值修改如下即可。

 

    error_reporting(E_ALL); //     測試用:E_ALL ; 上線用:E_WARNING

    
    //定義 Smarty的參數
    $smartyTpl = new Smarty();
    
    /*smarty v3 的寫法*/
    $smartyTpl->setTemplateDir(HOST_ROOT . "/smarty/templates/" )
                 ->setCompileDir(HOST_ROOT . "/smarty/templates_c/")
                 ->setConfigDir(HOST_ROOT . "/smarty/configs/")
                 ->setCacheDir(HOST_ROOT . "/smarty/cache/")
                 ->addPluginsDir(HOST_ROOT . "/smarty/plugins/");
   
    $smartyTpl->debugging = false; // true | false;
    //下列參數用預設值即可
    //$smartyTpl->caching = true;
    //$smartyTpl->cache_lifetime = 120;
    //$smartyTpl->force_compile = true;  // 若為 false 則 apache 的 mod_rewrite 做到網址轉換達成SEO優化 不正常
    //$smartyTpl->compile_check = true;
arrow
arrow
    文章標籤
    php smarty apache mod_rewrite
    全站熱搜

    MIS 發表在 痞客邦 留言(0) 人氣()