I’m a new CI developer dealing with security issues in one web site.
I have a url like:
http://myweburl/Everything/gov/2
which ‘2’ indicates the parameter to query db.
Here is my question:
If someone navigates following url:
http://myweburl/Everything/gov/2/order.txt
Actually nothing in the url, but..he will get an empty result page.(with reply 200 OK)
This is not what I wanted.
I hope he’ll get a 404 error or something else to tell users that nothing in the url.
Can anyone please give me some clues how to achieve my goal?
Thanks a lot!
Basically you only want to show a valid page if their is the correct number URI segments in the URL that represents a parameter in the query.
You should check the number of
URI segmentsas a pre-process before calling any other methods. This way you can be sure that there is in fact only 1 segment in the URLIf you find that there exists more than 3 segments in your
URL, then handle that situation accordingly with the convenient functions that CodeIgniter offers such Error Handling.You can check for the correct number of segments in the URL, and if it not what you want it to be, then call the
show_404()method.In the example URL you posted:
http://myweburl/Everything/gov/2/order.txt, there is actually 4 segments.