简体   繁体   English

Codeigniter重定向不起作用Ubuntu 18.04 LTS Server

[英]Codeigniter redirect not working Ubuntu 18.04 LTS Server

Codeigniter version 3.0.3 and PHP version 7.2. Codeigniter版本3.0.3和PHP版本7.2。 I have installed Ubuntu 18.04 Server OS with mysql,php and apache2. 我已经用mysql,php和apache2安装了Ubuntu 18.04 Server OS。 When I am running the codeigniter project in localhost, it works fine but not in the server. 当我在localhost中运行codeigniter项目时,它可以正常运行,但不能在服务器中运行。 It loads the login page but does not redirect to given page, it just refreshes the login page when valid credentials are provided. 它加载登录页面,但不重定向到给定页面,仅在提供有效凭据时刷新登录页面。 Help to solve this if somebody knows the issue. 如果有人知道问题,则有助于解决此问题。

Error when loading index page in the server 在服务器中加载索引页时出错

<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Warning</p>
<p>Message:  sizeof(): Parameter must be an array or an object that implements Countable</p>
<p>Filename: controllers/Login.php</p>
<p>Line Number: 57</p>


<p>Backtrace:</p>
        <p style="margin-left:10px">
        File: /var/www/html/sample/application/controllers/Login.php<br />
        Line: 57<br />
        Function: sizeof            </p>
        <p style="margin-left:10px">
        File: /var/www/html/sample/index.php<br />
        Line: 292<br />
        Function: require_once          </p>
</div>
{"status":true,"message":""}"

This error does not occur in localhost. 在本地主机中不会发生此错误。

enter image description here 在此处输入图片说明

In my case, i run the command in terminal 就我而言,我在终端中运行命令

sudo a2enmod rewrite sudo a2enmod重写

After that i restarted Apache 之后,我重新启动了Apache

systemctl restart apache2 systemctl重新启动apache2

In both cases you will need the admin password 在这两种情况下,您都将需要管理员密码

This is a warning, that takes palce on your local too but probably you have disabled warning or you are using a different version of PHP. 这是一个警告,也会在您的本地使用,但是您可能已禁用警告或正在使用其他版本的PHP。 Since you are parsing json, it won't be able to parse it because the response is mixed with warning so it's not in pure json format. 由于您正在解析json,因此它将无法解析,因为响应中混入了警告,因此它不是纯json格式。

sizeof takes an array or an object that implements Countable. sizeof采用一个数组或一个实现Countable的对象。 You can use this function after checking if the variable is an array or not by using this: 通过使用以下命令检查变量是否为数组后,可以使用此函数:

is_array($dataVariable)?sizeof($dataVariable):0

this will return zero if the variable is not an array. 如果变量不是数组,它将返回零。 You can disable warning as well on production. 您也可以在生产中禁用警告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM