.htaccess codeigniter multiple domains
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 maintan开发者_运维技巧ance.
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!
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>
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.
精彩评论