Welcome Guest, Not a member yet? Register   Sign In
404 header
#1

[eluser]vbsaltydog[/eluser]
This seems pretty obvious as a bug but I will put it here first for public opinion.

Bug in CI 2.1.0

If you have file extension suffix set in the config file and then you call a valid URL without the file extension suffix,
you get the correct page displayed in the browser but with a 404 header. Add the file extension suffix to the URL and the 404 becomes a 200
#2

[eluser]pickupman[/eluser]
I just tried this locally on Apache, and I am getting a 200 response when url_suffix is set to '.html'. Both index.php/welcome/index and index.php/welcome/index.html have a 200 status code.

If I set the url_suffix to be blank (default)
index.php/welcome/index => 200
index.php/welcome/index.html => 404

This seems to be the opposite of what you have described. The Router class calls:
Code:
$this->uri->_remove_url_suffix();

If it is set to blank then nothing is removed from the last segment making the Router parse the url as index.html as the method to run in your controller (index.html => index) giving a 404. This would the correct behavior. The inverse could be argued as bug or being correct. When the url_suffix is set, the Router class will remove it from the last segment, and the proper method will get called (index.html => index). If the suffix is not in the url, then the last segment still looks the same. (index => index).

I think latter behavior is correct because the last thing you want your users to see is a 404.
#3

[eluser]vbsaltydog[/eluser]
I am running HMVC, perhaps thats where the behavior is coming from.
#4

[eluser]pickupman[/eluser]
I haven't tried this with HMVC setup, but with the ongoing changes with some of the protected properties in the Loader and Router class, do you have the latest changeset from Modular Extensions?
#5

[eluser]vbsaltydog[/eluser]
I just updated the HMVC files just in case and the 404 error remains.
#6

[eluser]vbsaltydog[/eluser]
I just added HMVC to a default CI install with the suffix set and tested, there were no 404 headers sent with or without the URL suffix so I guess the error is coming from somewhere else. Time to debug.

Thanks for testing.
#7

[eluser]pickupman[/eluser]
I was just looking through the HMVC Router class but didn't see a palace where this would happen. I just about to do the same as you. Thanks for the heads up and good luck figuring it out.
#8

[eluser]vbsaltydog[/eluser]
I got it sorted out.

I was using this in my htaccess:

Code:
RewriteRule (.*).html$ index.php?/$1 [L]

Which obviously wasn't catching URIs that did not end in html

Thanks for testing so I could find my error.
#9

[eluser]pickupman[/eluser]
LOL...don't you love it when it is something simple like that.




Theme © iAndrew 2016 - Forum software by © MyBB