Most likely, issue is because of using relative URLs.
For example, those won't work when you are using deeper level URI segments.
Consider next few examples:
If base of your application is http://www.example.com/
which you should set in config file too by setting $config['base_url'] = 'http://www.example.com/';
, when you are on that URL with your browser, and when you click on some relative URL you will be pointed/redirected to URL that is current URL appended by relative link.
http://www.example.com/ => http://www.example.com/dashboard
but if you are in some deeper segment, let's say http://www.example.com/index/15
, dashboard
will be extending that one although you would like it points to http://www.example.com/dashboard
http://www.example.com/index/15 => http://www.example.com/index/15/dashboard
As other said, you should set and use base_url()
CodeIgniter inbuilt function (use appendix as parameter of function base_url('dashboard')
).
If you would like to use it without base_url('some-page')
function, you should use either absolute URL either relative to server route one.
The latter one would look like as with prepended slash that is telling web server to use root location defined in .htacces
file or virtual host environment settings /dashboard
. In your former example
<p><a href="/dashboard">Dashboard</a></p>
should work just well.
If it is not working you need to set RewriteBase attribute in .htaccess file.
Check this comment here and check some articles that describe differences, pro and cons between relative and absolute URLs