【问题标题】:codeigniter .htaccess godaddy dbcodeigniter .htaccess godaddy 数据库
【发布时间】:2013-03-23 07:41:26
【问题描述】:

家用控制器没问题

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

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

但是使用 index.php/[nameofcontrollerorroute] 它显示正常...我不认为 db 连接是问题,因为我可以访问 Home 控制器 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 托管,并且 codeigniter 位于子目录中,我已经在 stackoverflow 问题中尝试了不同的解决方案。有什么想法吗?

使用 XAMPP 可以很好地进行本地化

【问题讨论】:

    标签: php .htaccess codeigniter


    【解决方案1】:

    试试这个 .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>
    

    【讨论】:

    • 好吧,其实还是少了点东西,因为我没有强调这是在子目录中,那我应该补充:RewriteBase /beta/
    猜你喜欢
    • 2014-12-21
    • 2020-07-30
    • 1970-01-01
    • 2015-08-11
    • 1970-01-01
    • 1970-01-01
    • 2010-12-17
    • 2015-12-03
    • 2013-06-14
    相关资源
    最近更新 更多