【问题标题】:CodeIgniter 3 on remote server issuesCodeIgniter 3 关于远程服务器问题
【发布时间】:2018-02-25 12:20:24
【问题描述】:

我正在尝试使用 codeIgniter 项目设置生产服务器。 我所有的http 请求都重定向到login 页面的主页。 我遵循了 StackOverflow 的一些指示,但徒劳无功 以下是我的config.php 设置

$config['base_url'] = 'http://XXXXX.local/';
$config['index_page'] = '';
$config['uri_protocol'] = 'QUERY_STRING';

.htaccess 设置

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

还有我的sites-enabled 在启用 apache2 站点的设置中配置

<VirtualHost *:80>
    ServerName    XXXXX.local
    DocumentRoot "/var/www/html/xxx/index.php"
    <directory "/var/www/html/xxx/index.php">
        DirectoryIndex index.php
        AllowOverride all
        Order Allow,Deny
        Allow from all
    </directory>
</VirtualHost>

例如如果我在浏览器http://XXXXX.local/assets/js/jquery.validate.min.js 上打开,它会打开主页

我的会话也不起作用,它打印为空..我设置为 $this-&gt;session-&gt;set_userdata('test','hellow world'); 这是我的配置

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_cookie_name'] = '';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

请帮忙!

【问题讨论】:

  • “我所有的 http 请求都重定向到登录页面的主页。” - 我不知道这意味着什么。你能用一些例子来澄清这个问题吗?
  • 例如:如果我在浏览器http://XXXXX.local/assets/js/jquery.validate.min.js 上打开,它会打开主页@MagnusEriksson
  • 您的 Apache 配置错误。文档根目录应该是文件夹,而不是文件。在这两个地方将"/var/www/html/xxx/index.php" 更改为DocumentRoot "/var/www/html/xxx"
  • 我也看不到这行的目的:RewriteCond $1 !^(index\.php|resources|robots\.txt) 在你的 htaccess 中?
  • @MagnusEriksson 你说得对,请写一个答案,我可以接受

标签: php .htaccess codeigniter-3 apache2.2


【解决方案1】:

Apache 配置中的文档根目录必须是文件夹,而不是文件。

改变

DocumentRoot "/var/www/html/xxx/index.php"
<directory "/var/www/html/xxx/index.php">

DocumentRoot "/var/www/html/xxx"
<directory "/var/www/html/xxx">

更新配置后不要忘记重启 Apache。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-12
    • 2010-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多