Welcome Guest, Not a member yet? Register   Sign In
Controller VS Seo

Hi there,

I have a question about the duplicate page.

Actually, for default, the typical page in a CodeIgniter framework is something like this:


where site is the controller containing the contact function that point to the contact.html view...
To have a better URL I use a trick with the "routes" that redirect any http://www.domain.com/contact to the original http://www.domain.com/site/contact
Of course the both are valid and the both are... crawled! So I get the duplicate page.

Is this something I have to manage, maybe with .htaccess?

Any idea would be very appreciated.

Thanks for you precious time guys!


If you have a route like
$route['contact'] = 'site/contact';
Then make all of your links just point to "contact" for the url, and not "site/contact".
If you have both kinds of links on your site, then they will both be cataloged. Google will only catalog links that are actually on your site. If you never link to "/site/contact", then google will never know about it.

Routes don't "redirect". They don't issue a 301 redirect header to tell the browser that the requested resource has permanently changed locations. They just take the requested url and execute something other than "controller/method/params" like how CI handles them by default.

In the meantime, yes I'd set up a 301 redirect in your htaccess.
Redirect 301 /site/contact http://yoursite.com/contact

so I will use the redirect.

By the way I can't understand where it take the real link because I never used it and some program crawled it anyway :-s



I've never had that happen and I run a fairly large site on CI. Are you sure there aren't any links anywhere? I would text search all of your views for "site/contact". Is this a redesign of an old site where the older links might have existed and therefore already cataloged? Was your site live with the old links before you created and started using the route? Are they in a sitemap.xml perhaps? If those links previously existed at any point in time, that's probably where google/SE got them from and since there wasn't anything telling it that it's relocated via 301, then it stays because its still crawlable.

So you really need to make sure:
1) Those /site/contact links are totally gone
2) 301 Redirect old to new

They will eventually drop off of google, but only if both of those things are true.


You can also try adding the duplicates to your robots.txt, or check the URL on the page and add the respective meta tags to block indexing if its being accessed using /site/contact.

If SEO is important to your site you should create a module that outputs a sitemap.xml that you can upload to Google and allow Google to check periodically for new content. Having a list of site pages is better then having Google try to find them all.

Thanks to everybody.
I will start to use the 301 Redirect to be sure crawlers understand that the two url are going at the same content and page.


Duplicate pages are not a problem if you use the canonical tag:

<link rel="canonical" href="http://www.yoursite.com/contact" />

The tag tells search engines to disregard duplicate pages and concentrate on the 'canonical' version of the page.

If you are using a single header file for all your pages then you can pass the canonical through to the view from the controller, and have a default canonical so that you don't have to explicitly set it on every controller:

<link rel="canonical" href="http://www.yoursite.com/<?php echo isset($canonical) ? $canonical : $this->uri->uri_string()?>">

Further reading about the canonical tag here:


Hope that helps!

Great link! Thanks.

Theme © iAndrew 2016 - Forum software by © MyBB