I am creating a glossary for my website that will display definitions for terms on my site.
I have everything working. But I would like to show a 404 if my uri segment 3 contains anything other than the letters in the alphabet.
My glossary urls currently look like:
www.mydomain.com/tools/glossary/a
www.mydomain.com/tools/glossary/b
www.mydomain.com/tools/glossary/c
...
I want to show a 404 if the user enters a string that is not in the alphabet:
example
www.mydomain.com/tools/glossary/tree
In my glossary function I have added the following:
if($this->uri->segment(3)) {
if($this->uri->segment(3) !== 'a' || 'b' || 'c' .... 'z') {
show_404();
}
}
How can I get the above code to work??
Show a 404 if the 3rd uri segment does not equal a letter between a and z??
You could try this (controller tools.php)
Tests: