家庭控制器还可以
使用重写无法访问其他Codeigniter控制器,而是显示
Database connection error (2): Could not connect to MySQL.
但是使用index.php / [nameofcontrollerorroute]它正常显示...我不认为db连接是问题,因为我可以访问家庭控制器w / c已经连接到db,当然,并使用索引.PHP / [nameofcontrollerorroute]
htaccess的:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
我也尝试过更改配置值[uri_protocol& index_page]但仍然没有变化。
我正在使用GoDaddy Hosting并且codeigniter位于子目录中,我已经在stackoverflow问题中尝试了不同的解决方案。任何想法?
使用XAMPP ,localhosting非常好答案 0 :(得分:2)
试试这个.htaccess适用于我的网站,该网站位于codeigniter并托管在godaddy上。
<IfModule mod_rewrite.c>
RewriteEngine On
#AddHandler application/x-httpd-php5 .php
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]
#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>