CodeIgniter 3.0 .htaccess 不工作
CodeIgniter 3.0 .htaccess not working
我有一个用于 Codeigniter 2.2.0 的 .htaccess
文件,当我在我的控制器中使用子目录时它运行良好。但是在 Codeigniter 3.0 中,我无法通过 link http://localhost/myproject
访问我的网站
不过,以下 link 的工作:
http://localhost/myproject/index.php/frontend/home
http://localhost/myproject/frontend/home
我的路线很明确
$route['default_controller'] = 'frontend/home/index';
还有我的.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 !^(index\.php|public|robots\.txt)
# do not rewrite for php files in the document root, robots.txt or the maintenance page
RewriteCond !^([^\..]+\.php|robots\.txt|sitemap\.xml)
# but rewrite everything else
RewriteRule ^(.*)$ index.php?/ [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>
在装有 codeigniter 3.0 的 $route['default_controller']
上,您不能再使用子文件夹。
It was a bug in CI2 that allowed you to put folders in default route
对于$route['default_controller']
,控制器必须位于主控制器位置,如下所示。
任何其他控制器仍然可以有子文件夹,但默认控制器必须在第一级控制器中。
application
application > controllers
application > controllers > Home.php
注意:您需要class的首字母和文件名设置为大写,如下所示。
Routes.php
$route['default_controller'] = 'home/index';
如果您需要在 codeigniter 3 中使用带有 $route['default_controller']
的子文件夹,我建议您使用 HMVC,这样您就可以在路由中的 $route['default_controller']
中拥有子文件夹。
注意:HMVC 仅适用于 CI3
https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/downloads
godaddy中所有控制器的第一个字母class必须大写。在 codeigniter 3.0 中 100% 工作 ->
喜欢:
应用程序 > 控制器 > Home.php
我有一个用于 Codeigniter 2.2.0 的 .htaccess
文件,当我在我的控制器中使用子目录时它运行良好。但是在 Codeigniter 3.0 中,我无法通过 link http://localhost/myproject
不过,以下 link 的工作:
http://localhost/myproject/index.php/frontend/home
http://localhost/myproject/frontend/home
我的路线很明确
$route['default_controller'] = 'frontend/home/index';
还有我的.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 !^(index\.php|public|robots\.txt)
# do not rewrite for php files in the document root, robots.txt or the maintenance page
RewriteCond !^([^\..]+\.php|robots\.txt|sitemap\.xml)
# but rewrite everything else
RewriteRule ^(.*)$ index.php?/ [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>
在装有 codeigniter 3.0 的 $route['default_controller']
上,您不能再使用子文件夹。
It was a bug in CI2 that allowed you to put folders in default route
对于$route['default_controller']
,控制器必须位于主控制器位置,如下所示。
任何其他控制器仍然可以有子文件夹,但默认控制器必须在第一级控制器中。
application
application > controllers
application > controllers > Home.php
注意:您需要class的首字母和文件名设置为大写,如下所示。
Routes.php
$route['default_controller'] = 'home/index';
如果您需要在 codeigniter 3 中使用带有 $route['default_controller']
的子文件夹,我建议您使用 HMVC,这样您就可以在路由中的 $route['default_controller']
中拥有子文件夹。
注意:HMVC 仅适用于 CI3 https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/downloads
godaddy中所有控制器的第一个字母class必须大写。在 codeigniter 3.0 中 100% 工作 ->
喜欢: 应用程序 > 控制器 > Home.php