默认推荐 CodeIgniter .htaccess 文件:
<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>
为您的目的调整 CI .htaccess 文件(您知道,晚了一年):
<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>