2013-03-22 40 views
0

我在web根目录下有我的codeigniter代码。 mod_rewrite启用..我通过phpinfo.php检查。现在,代码结构是这样的CodeIgniter不能使用子文件夹

controllers/home.php(default controller) 
    controllers/products.php (not listed in routes.php under config) 
    and then a subfolder 
    controllers/members/login.php 

我想要的网址是

domain_name/ ---------> works 

(注:这是我的回声BASE_URL指向我我猜 因为$配置[ '的index.php'] = '',但即使将其设置为的index.php是 不是指向我工作的index.php URL)

domain_name/products ------> doesn't work 
    domain_name/index.php/products ------> works 
    similarly 
    domain_name/members ----->doesn't work 
    domain_name/index.php/members --->work 

因为这件事情正在与index.php工作,我猜想routes.php工作正常。但是,一些echo $ base_url指出我没有使用index.php url。

我曾尝试.htacess文件,该文件是在我的根目录是在/ var/WWW/ 版本的笨是2.1.3

请帮助。我希望这与无index.php工作,如果你能解释我失踪,请给我解释。

回答

0

在一般Codeigniter倾向于明确隐藏index.php时调用其主要的根,但是当你试图直接访问其子文件夹在url .. index.php是必需的。为了做到这一点,你必须包括一个您的CI文件系统内的.htaccess将接受使用域/产品或域/ index.php文件/产品

所以尽量包含此.htacess并改变其重写基地到您的CI文件夹名称

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase /cifolder 

    #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> 
相关问题