Wednesday, November 30, 2011

CodeIgniter + WebHosting

These are a few difficulties that can be met when installing or migrating to CogeIgniter (CI) in a webhoting server.

1. pconnect (DataBase)

    It should be checked by phpinfo.
    If it is disabled, then change the value in application/config/database.php

        $db['default']['pconnect'] = FALSE;


2. index.php and .htaccess (Apache)

    If the CodeIgniter directory is not in the root but under a direcotory,
    then there might be a small change in .htaccess

        /A DIRECTORY/CodeIgniter Directory/.htaccess
            RewriteBase /CodeIgniter Directory/

3. base_url()

    If it is not in the root directory, then base_url() should be prefixed in every links.


  $cjspath = base_url() . $this->config->item('cjs');
  $module_path = $cjspath . "/$module";
  $common_path = $cjspath . "/common";


        echo "<script type='text/javascript'>\n//<![CDATA\nBASE_URL='" . base_url() . "'\nLOGGEDIN=$loggin;\n//]]></script>";

    There are two exceptions that the base_url() is not necessary!
    (using base_url() produces the same effect, though)
    1. the src in <a> tag as in <iframe src='dafk'>
    2. when using link_tag('adkf') like echo link_tag($cssfile);


No comments:

Post a Comment