CodeIgniter Forums
URL problems with codeigniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: URL problems with codeigniter (/showthread.php?tid=59862)



URL problems with codeigniter - El Forum - 12-01-2013

[eluser]Unknown[/eluser]
Hi,

Lets say you have a website called www.yourwebsite.com

now with codeigniter usually the url ends up something like this:

www.yourwebsite.com/controller/page/

controller is the name of the controller and page is the name of the page loaded.

Now that is the url.

However if you type this in your browser:

www.yourwebsite.com/controller/page/893736573/nvfrjghfvrug3

the controller will load 'page'.

I want it to instead redirect to 404 error.

Is this possible in codeigniter and how is it done?

Sorry about the bad title to the topic not sure how to word this or the correct terminology. I hope this explains what I mean in enough detail.

Kind regards,

zorax





URL problems with codeigniter - El Forum - 12-01-2013

[eluser]CroNiX[/eluser]
In your controller, check to see if the page actually exists, and if not,
Code:
show_404();

CI will only show a 404 if the requested controller or method doesn't exist. It's up to you to do the rest by verifying any additional parameters/segments.


URL problems with codeigniter - El Forum - 12-02-2013

[eluser]Unknown[/eluser]
Hi,

Thank you for your reply, in the example 'page' does exist as a method in the controller I want it so that if someones adds extra 'parameters' to the page method such as '\8723563\87nhkvbvhfb' it will go to 404 error instead of loading page. How would this be done?

Kind regards,

Zorax



URL problems with codeigniter - El Forum - 12-02-2013

[eluser]noideawhattotypehere[/eluser]
Code:
if($this->uri->segment(4, 0) !== 0) {
    show_404();
}