Khanh Hoang - Kenn
Kenn is a user experience designer and front end developer who enjoys creating beautiful and usable web and mobile experiences.
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.com
is accessible and if http://yourdomain.com
is (without redirection to one of the two). If so, this article is for you.
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.com
and 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.
How can you solve this? Easy. Open your Drupal installation's .htaccess file and look for the following part.
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.com
and I would like to redirect all my urls to the www-having domain I would do the following:
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