Welcome Guest, Not a member yet? Register   Sign In
URL problems with codeigniter
#1

[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


#2

[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.
#3

[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
#4

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




Theme © iAndrew 2016 - Forum software by © MyBB