Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 Error in pathinfo mode #1965

Closed
viosion opened this issue Apr 23, 2019 · 0 comments · Fixed by #1968
Closed

404 Error in pathinfo mode #1965

viosion opened this issue Apr 23, 2019 · 0 comments · Fixed by #1968

Comments

@viosion
Copy link
Contributor

viosion commented Apr 23, 2019


name: Bug report
about: Help us improve the framework by reporting bugs!


Describe the bug
When set uriProtocol = 'Pathinfo'
Close debug, got 404 error;

line 578 in Router.php

// '/home/index' $segments = [0=>'', 1=>'home', 2=>'index']
protected function validateRequest(array $segments)
{
$segments = array_filter($segments); // $segments = [1=>'home', 2=>'index']

Because array_filter() gets the result array, the index is not updated. So pathinfo '/home/index'([0=>'', 1=>home, 2=>index]) gets [1=>home, 2=>index], there is no $segments[0]; Controller cannot be found, resulting in 404;

line 587 in Router.php
`

$this->directory . ucfirst($this->translateURIDashes === true ? str_replace('-', '_', $segments[0]) : $segments[0]

`
ErrorException
Undefined offset: 0
SYSTEMPATH/Router/Router.php at line 587

Then add a line below:
$segments = array_filter($segments);
$segments = array_values($segments);
May solve this problem;

CodeIgniter 4 version
Codeigniter 4.0.0-beta.2

Affected module(s)
Router

Expected behavior, and steps to reproduce if appropriate

Context

  • OS: [Mac OS 10.14.4]
  • Web server [Nginx 1.13.2]
  • PHP version [7.2.14]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant