删除codeigniter子域的index.php

时间:2012-03-05 19:24:19

标签: .htaccess codeigniter subdomain

这是我的目录:

-root
   -CI
     -application
     -system

   -sub-domain1 (codeigniter )
     -application

   -sub-domain2 (codeigniter )
     -application


   -www
     -folder1
     -folder2
     .....
     -folder10
     -sub-domain1
         -index.php (used for codeigniter)
     -sub-domain2
         -index.php (used for codeigniter)
     -file1.php
     -file2.php
     -file3.php
     .....
     -file10.php
     -index.php (used for codeigniter)
     - .htaccess
我的application / config / config.php中的

是:

$config['index_page'] = "";

我没有子域1和子域2,我想现在应用它们。我对所有CI使用相同的系统。我使用了以下htaccess文件,它完美无缺。

RewriteEngine On
RewriteBase /

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php
</IfModule> 

现在当我添加sub-domain1和sub-domain2时,我对index.php有问题。对于主要的CI index.php已经不见了,但对于子域我不知道如何做到这一点。

www.mydomain.com/folder1/...           ok 

www.mydomain.com/controler/function    ok

www.sub-domain1.mydomain.com/index.php/controler/function  ok

www.sub-domain1.mydomain.com/controler/function  NOT ok

请帮帮我。 感谢

1 个答案:

答案 0 :(得分:0)

您应该能够跨所有CI安装共享系统目录,为升级提供中心位置,并使用更少的磁盘空间。

查看application / config / config.php

和行:$config['index_page'] = "index.php";

应如下所示:$config['index_page'] = "";