0

I'd like to know if it is possible to organize the following structure of the CodeIgniter installation:

- Main folder
-- codeigniter
-- images
-- site1-application
-- site2-application
-- site1-index.php
-- site2-index.php

The main idea is to use the same images and codeigniter folder across the multiple web sites for easier maintanance.

For now I do have two web sites that are resides in two standard installations and I'm unable to share the images folder nor to update system libraries simulaneously at multiple web sites.

I've played alittle with the .htaccess file, but no luck for me :(

Thanks in advance!

Evan
  • 1
  • 1

2 Answers2

2

Default recommended CodeIgniter .htaccess file:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  #CodeIgniter
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /index.php/$1 [L]
  RewriteRule ^$ /index.php [L]
</IfModule>

Tweaked CI .htaccess file for your purposes (you know, a year too late):

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  #CodeIgniter
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d

  # Check for Domain 1 with a path
  RewriteCond %{HTTP_HOST} domain-1.com
  RewriteRule ^(.*)$ /site1-index.php/$1 [L]
  # Check for Domain 1 without a path
  RewriteCond %{HTTP_HOST} domain-1.com
  RewriteRule ^$ /site1-index.php [L]

  # Check for Domain 2 with a path
  RewriteCond %{HTTP_HOST} domain-2.com
  RewriteRule ^(.*)$ /site2-index.php/$1 [L]
  # Check for Domain 2 without a path
  RewriteCond %{HTTP_HOST} domain-2.com
  RewriteRule ^$ /site2-index.php [L]
</IfModule>
ebynum
  • 3,494
  • 1
  • 18
  • 15
  • This worked for me, but I had to add another RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d between Domain 1 and Domain 2 (on empty line) – TomoMiha Jan 19 '17 at 12:33
0

Yes, it's possible.

Use .htaccess to direct all trafic from one domain to site1-index.php and all traffic from another domain to site2-index.php.

The location of CI Application and System folders is set in the *-index.php files.

micflan
  • 173
  • 10
  • Thank you for your answer. Could you, please, help me with the .htaccess scripts, because they looks like a voodoo rather than programming? – Evan Sep 22 '10 at 02:11