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

 
Xây dựng ứng dụng Drupal Learn Words trên Mobile

Xây dựng ứng dụng Drupal Learn Words trên Mobile

In this tutorial we'll explore how to make a simple mobile application game with DrupalGap for a Drupal 7 website. Our game will help us learn words in another langauge.

Tuyển sinh khóa học Drupal Themer tại Bình Dương

Môi trường làm việc, Basic HTML, Cơ bản PHP, Basic CSS, HTML5 cho themer, Javasript cho themer, Theme Engine, PHPTemplate:

Steve Jobs khuyên gì để cha đẻ Facebook thành tỷ phú?

Steve Jobs khuyên gì để cha đẻ Facebook thành tỷ phú?

Thông tin này được đưa ra trong cuộc phỏng vấn mới đây giữa PBS với Zuckerberg và Giám đốc điều phối Sheryl Sandberg của Facebook.

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

 

Diet con trung