Welcome Guest, Not a member yet? Register   Sign In
show 404 question
#1

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
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#2

(This post was last modified: 03-29-2015, 01:14 AM by Muzikant.)

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
Reply
#3

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB