2015-09-19 133 views
1

我有這個.htaccess文件,我使用Codeigniter 2.2.0,並且在我的控制器中使用子目錄時效果很好。但在笨3.0我無法通過鏈接http://localhost/myprojectCodeIgniter 3.0 .htaccess不能正常工作

Althought訪問我的網站,以下環節的工作:

http://localhost/myproject/index.php/frontend/home

http://localhost/myproject/frontend/home

我的路線是明確界定

$route['default_controller'] = 'frontend/home/index'; 

And my .htaccess

Options -Indexes 
Options +FollowSymLinks 

# Set the default file for indexes 
DirectoryIndex index.php 

<IfModule mod_rewrite.c> 

    # activate URL rewriting 
    RewriteEngine on 

    # do not rewrite links to the documentation, assets and public files 
    RewriteCond $1 !^(index\.php|public|robots\.txt) 

    # do not rewrite for php files in the document root, robots.txt or the maintenance page 
    RewriteCond $1 !^([^\..]+\.php|robots\.txt|sitemap\.xml) 

    # but rewrite everything else 
    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. 

    ErrorDocument 404 index.php 

</IfModule> 

回答

1

在codeigniter 3.0的$route['default_controller']上,您不能再使用子文件夾。

正是在CI2,允許你把文件夾在默認路由

對於$route['default_controller']控制器必須是主控制器的位置如下圖所示的錯誤。

任何其他控制器仍然可以有子文件夾,但默認控制器必須位於第一級控制器中。

application 

application > controllers 

application > controllers > Home.php 

注意:您需要將類和文件名的第一個字母設置爲大寫,如下所示。

routes.php文件

$route['default_controller'] = 'home/index'; 

如果您需要在笨3使用的子文件夾與$route['default_controller']我會建議使用HMVC,這將讓你有子文件夾中$route['default_controller']的路線。

注:HMVC僅CI3 https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/downloads

0

在所有的控制器類必須是大寫GoDaddy的第一個字母。在笨工作100%3.0 - >

像: 應用>控制器>ħ ome.php