0
votes

I have a routing question for CodeIgniter.

I have two applications sharing the system folder with the following folder structure

./admin
./admin/index.php
./admin/{stylesheets, scripts, images, etc}

./site
./site/index.php
./site/{stylesheets, scripts, images, etc}

./applications/admin
./applications/admin/{controllers, models, config, etc.}
./applications/site
./applications/site/{controllers, models, config, etc.}

./system

All is working ok, except that I can only access my site as domain.com/site/controller_name/method_name. How can I get rid of the site part?

Also, is there an easy way to share helpers and libraries between the applications? Besides putting them in system/helpers.

Thanks!

1
You basically do this with sub-domains, making the default www.yoursite.com and yoursite.com lead to site folder and make a sub-domain admin.yoursite.com that will point to your admin folder. Or another way would be to write an .htaccess if you're on Apache and put it to your web root folder. Regarding shared helpers and libraries, you can use third party/packages ellislab.com/codeigniter/user-guide/libraries/loader.html or you can always simply include(). - Sergey Telshevsky
@Vlakarados It's an .htaccess/$routes[] solution I was after, how should the htaccess rule look like? - Illes Peter

1 Answers

0
votes

Try changing your root folder's .htaccess to

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteRule ^$ site [L]