0

家用控制器没问题

无法使用重写访问其他 Codeigniter 控制器,而是显示

Database connection error (2): Could not connect to MySQL.

但是使用 index.php/[nameofcontrollerorroute] 它正常显示...我不认为数据库连接是问题,因为我可以访问 Home 控制器 w/c 已经连接到数据库,当然,并使用 index.php/ [名称控制器或路由]

.ht 访问:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

我还尝试更改配置值 [uri_protocol & index_page],但仍然没有更改。

我正在使用 GoDaddy 托管,并且 codeigniter 位于子目录中,我已经在 stackoverflow 问题中尝试了不同的解决方案。有任何想法吗?

使用 XAMPP 进行本地化非常好

4

1 回答 1

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>
于 2013-04-02T05:47:14.350 回答