【问题标题】:codeigniter problem - site redirects to localhost after migratingcodeigniter 问题 - 迁移后站点重定向到本地主机
【发布时间】:2011-05-23 09:04:21
【问题描述】:

我刚刚将 CI 文件从服务器复制到我的本地主机,但我在运行该站点时遇到了问题。

每当我点击 WAMP 中的站点链接时 http://localhost/CmpOnline/

它显示了与本地主机相同的文件夹列表

这是我的 htaccess 文件

RewriteEngine on
RewriteCond $1 !^(index\.php|images|javascript|stylesheets|uploads|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

在配置文件中

$config['base_url'] = "http://localhost/CmpOnline/";

$config['index_page'] = "";

$config['uri_protocol'] = "REQUEST_URI";

我将其更改为所有其他可用选项,但它仍然不起作用

我试过这个 .htaccess and codeigniter not working 还有这个 Remove index.php From URL - Codeigniter 2

但它仍然不起作用。

有什么帮助吗?

【问题讨论】:

    标签: .htaccess codeigniter


    【解决方案1】:

    你应该有一个RewriteBase:

    RewriteEngine on
    RewriteBase /CmpOnline
    RewriteCond $1 !^(index\.php|images|javascript|stylesheets|uploads|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    

    因为RewriteRule 将所有内容发送到RewriteBase 的根,默认为/(CodeIgniter 仍然需要base_url 设置,因为它的内部内容)。

    【讨论】:

      【解决方案2】:

      如果

      $config['uri_protocol'] = "REQUEST_URI";
      

      改成

      $config['uri_protocol'] = 'PATH_INFO';
      

      如果使用这个

      $config['uri_protocol'] = 'ORIG_PATH_INFO';
      

      重定向或标头位置到不在 htaccess 中的 url 将不起作用,您必须在 htaccess 中添加 url 才能工作

      【讨论】:

        【解决方案3】:

        Options +FollowSymLinks
        RewriteEngine on
        
        # Send request via index.php
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php/$1 [L]
        

        【讨论】:

        • 请在您的答案周围添加一些解释。
        猜你喜欢
        • 2017-12-20
        • 2014-02-20
        • 2017-09-13
        • 1970-01-01
        • 2018-07-04
        • 2016-04-23
        • 2017-05-16
        • 1970-01-01
        • 2018-02-16
        相关资源
        最近更新 更多