Search code examples
phpcodeigniterdirectory-structure

Codeigniter - share project files for duplicating website to mobile website


I need to replicate the website on another domain. the both domains will share same db and same logic behind.

Now assuming this is my application scheme.

application
js
css
system
.htaccess
index.php

Which is the best practice do replicate the site for the other domain ?

What i need to know before to start ?

NB: basically i just have to duplicate the html,css and js , for mobile site domain so i'll have www.site.com and www.mobile.site.com


Solution

  • This is what your directory structure could look like:

    -/home/yourdomain
        -public_html
            -index.php
            -.htaccess
            -mobile
                -index.php
                -.htaccess
            -assets
                -js
                -css
                -img
                -etc
        -your_application
            -system
            -application
    

    To share the same CodeIgniter installation and application, you could place the system and application folder above the web root - which is a good idea anyway (in this example it is in the your_application directory).

    Assuming that your domain is pointing to: public_html and the mobile domain is pointing to: public_html/mobile, then you would add CodeIgniter's default index.php to both locations. Update both of these files to point to the system folder and application folder:

    $system_folder = /home/yourdomain/your_application/system;
    $application_folder= /home/yourdomain/your_application/application;
    

    The assets are publicially accessible, so just ensure that the HTML you generate points to the correct location, for example: http://yourdomain.com/assets/css/main.css