CodeIgniter Forums
show 404 question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: show 404 question (/showthread.php?tid=1645)



show 404 question - wolfgang1983 - 03-28-2015

Hi,

Just have a question about show404. If my <a href=""> is empty how can I make it go to page not found or error 404 on codeigniter?

Currently if link is empty <a href=""> goes to home page.

Thanks in advance


RE: show 404 question - Muzikant - 03-29-2015

I think you can not. The browsers always leads to the same page. If you are generating links in controller, just check if every anchor has its value, even the wrong one, which will lead to 404 error message page. The same if you are handling the users input. You can replace empty values with "404", for example to "<a href="404">Some link</a>:

PHP Code:
$input '<a href="">Some link</a>';
$output str_replace('<a href="">''<a href="404">'$input);
echo 
$output



RE: show 404 question - logsdon - 03-29-2015

An empty href="" will just link to the page you are on. If you are on the homepage already, that's why the link keeps going there. You actually have to link to a page that does not exist to get a 404.

So if you just installed CI, have a link to href="<?php echo site_url('welcome/does-not-exist'); ?>" for example.