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

 

Hướng dẫn viết module drush command trong Drupal 7

Experienced Drupal coders can hardly do without Drush (Drupal shell) utility as it speeds up a good deal of routine function along the way.

Mac OS X Lion bất ngờ tăng trưởng chậm

Mac OS X Lion bất ngờ tăng trưởng chậm

Chỉ mất hai tháng để OS X Lion được cài đặt trong 14% người dùng máy Mac nhưng trong tháng 10 vừa qua lại chỉ tăng 2%.

Nguy cơ rò rỉ thông tin từ thiết bị viễn thông nhập khẩu Trung Quốc là  Huawei và ZTE

Tập đoàn viễn thông Huawei và ZTE đe dọa an ninh nước Mỹ

Không phải đến bây giờ, khi Ủy ban Tình báo Hạ viện Mỹ vừa công bố hai tập đoàn viễn thông Trung Quốc là Huawei và ZTE đe dọa an ninh nước này, các khuyến cáo về sử dụng các thiết bị tương tự tại Việt Nam mới được đưa ra.

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

 

Diet con trung