Duplicate content error results instead of a 404 page

Duplicate content error results instead of a 404 page - .htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, codeigniter, , , .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :


My current URL is: www.example.com/category/we-developer/ However, if any user mistakenly adds extra characters after the /, for example, www.example.com/category/we-developer/fgggfgg, it should take him to a 404 page. But instead, the user is again viewing the previous page (www.example.com/category/we-developer/)



This is why Google is showing it as a duplicate page. What I wish is that instead of opening the same page, the user would be taken to a '404` page.



Can you advise on how to do this? Note that my site is using CodeIgniter.


Solution :

I wouldn't necessarily serve up a 404.



If users are actually linking to your content this way, then changing your application to serve up a 404 will result in a loss of backlinks. i.e. All links to www.example.com/category/we-developer/fgggfgg will be lost. Instead, I would make use of canonical URLs:



<link rel="canonical" href="http://www.example.com/category/we-developer/" />


This will tell Google that the original content is on http://www.example.com/category/we-developer/ and that said content can be accessed via multiple URLs.



This way, you fix the duplicate content issue without losing out on previously-posted links.



CodeIgniter's code sounds actually quite good for usability - if it can't find a page, it takes you to the category where that page is likely to be rather than returning nothing.



Pages you have knowingly changed the URL of are better 301d rather than 404d so they go to exactly the right page.



The only potential duplicate content problem here is if Google accidentally index the wrong version of a page. They could only do that if any links are pointing to the wrong URL. It is not going to be treated any more a new page than the fact that every site on the web can have new duplicate pages by appending a parameter to the URL. They are usually pretty good at recognising which URL is canonical. If not, help them out with a canonical tag.



(If you really need to change the routing rules, then a Google tells me they are set at application/config/routes.php - though make sure you follow any override guidelines instead of hacking at core code)


Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.

Comments

Popular posts from this blog

Rewrite in Mediawiki, remove index.php, .htaccess

.htaccess rewrite wildcard folder paths from host

Using .htaccess to set a cookie and 301 redirect