Imagine we have the controller
class Test
{
public function index()
{
echo 'hello!';
}
}
So I can call it like test/index or for the best practice set route something like $routing['test'] = 'test/index';
So now I can call it with two ways test or test/index and same page have two links! So I want to know what would be the best solution for this situation?
All that I am thinking maybe check in index if I have in segment 'index' so redirect to route just 'test'.
I working with Codeigniter but I think this is question is SEO'specific too.
Summary: What would be the best to prevent double linking for the same content if I use routing?
Thanks!
Wall called .htaccess
rule stopped you. Try this way:
#instead of test put name of your default controller
RewriteRule ^(test(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
I found this great piece of code on this page where you can see basic but extensive .htaccess
file for use in CI made websites / applications.