Performance and SEO impact of not rewriting your urls to use or not use www

Performance and SEO impact of not rewriting your urls to use or not use www

Here's a quick tip which will influence your performance and SEO. It's just about uncommenting 2 lines of code in the .htaccess file that ships with Drupal (and replacing some text), but I've seen a lot of sites that tend to forget this.

Suppose your domain is something like yourdomain.com. Check now if you can access your site by prefixing your domain with www.and by not doing it. So check if http://www.yourdomain.comis accessible and if http://yourdomain.comis (without redirection to one of the two). If so, this article is for you.

The problem

If you have Drupal's page cache enabled, 2 cache entries will be generated for your page if you visit the same page on http://www.yourdomain.comand http://yourdomain.com. This is because the cache key Drupal generates is based on the full url (well, actually the cache key is the full url). This means your cache hit rate will be lower and the performance gain you'd get from caching will be not as high.

Another issue with this is that this will have some impact on your search engine results ranking. Suppose half of the people use the www-less domain, and the other half will use the www-having domain, then the score of your page for search engines will be shared between the two pages.

The solution

How can you solve this? Easy. Open your Drupal installation's .htaccess file and look for the following part.

Performance and SEO impact of not rewriting your urls to use or not use www

If you read the comments in this part, you'll know what to do. Just uncomment the 2 lines that apply to your case (would you like to use the www-having or the www-les urls?).

For example, suppose my domain is mydomain.comand I would like to redirect all my urls to the www-having domain I would do the following:

Caveat

Just a little caveat. If you update your Drupal installation, the .htaccess file will be overriden (unless you don't explicitly don't overwrite it). In case you override your .htaccess file when updating, just make sure you redo these modifications

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Khanh Hoang

Khanh Hoang - Kenn

Kenn is a user experience designer and front end developer who enjoys creating beautiful and usable web and mobile experiences.

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
CMS Drupal, Drupal Modules, Web Matrix

20 Drupal Modules làm tăng chức năng Website

Drupal is a robust content management system that can do nearly anything you throw at it.

5 tính năng quan trọng của Open Atrium 2 cho Education

5 tính năng quan trọng của Open Atrium 2 cho Education

Being able to effectively and efficiently collaborate with colleagues is something that every organization struggles with. Whether it be the process in which collaboration occurs or the tool that facilitates the process

Tổng hợp hầu hết các comment spam trong Drupal 7

Tổng hợp hầu hết các comment spam trong Drupal 7

Mollom does a great job at reducing spam, but it does leave behind enough spam to make you question allowing comments at all.

Công ty diệt chuột T&C

 

Diet con trung