I am in the process of migrating my sites from A Small Orange to Media Temple. Part of that process involves canonicalizing domain URLs to help maximize SEO strategy. At ASO, URL canonicalization required just a few htaccess directives:

When placed in the web-accessible root directory’s htaccess file, that snippet will ensure that all requests for your site are not prefixed with www. There’s also a force-www technique if that’s how you roll. Either way, the point is that on most shared hosting, URL canonicalization is simple.

Canonical URLs using Plesk

Using Plesk at Media Temple on a dedicated virtual (dv) machine, URL canonicalization requires a few more steps. I am no Plesk/(mt) expert, but this is what works for me. As with everything, your mileage may vary.

Choose your primary domain – in Plesk, click on Server > IP Addresses. In the far-right “Hosting” column of your IP list, click on the number. You should see your domains listed. Pick your primary and click “Set As Default”.

Enable www – This is the trick: even if you don’t want to use the www prefix, you need to enable it before canonicalizing your URLs. So, for each of your domains, click on the “Domain Administrator” button and put a checkmark in the “www” box (near the top of the options list).

Canonicalize via htaccess – once your primary is set and all domains have the www feature enabled, just add the following htaccess code to each domain’s httpdocs directory:

That’s it! Your domains should now resolve to either the www or non-wwwURL. Remember to test thoroughly!

Adding & canonicalizing other subdomains

Technically, the www prefix is treated as a subdomain. On (mt) (dv), all non-existent subdomain URLs are by default routed to the primary domain. Here is an example:

My primary domain is monzilla.biz, and I also have a domain named cssresetr.com

A request is made for something.cssresetr.com, which doesn’t exist

The server returns the content from my primary domain, monzilla.biz, with the address bar still showing something.cssresetr.com

Whether or not this default functionality is problematic depends on your situation, but it can cause problems when actual, existing subdomains are involved. For example, I have a subdomain, images.monzilla.biz, that will eventually host my image content. Creating the images subdomain in Plesk is easy, but if someone requests the images subdomain via another domain, such as images.cssresetr.com, they’ll get the following:

The primary domain’s home page (instead of the actual, requested domain)

The URL remains as images.cssresetr.com in the address bar (even though that’s not what they are looking at)

Not really the best user experience, but that’s the default functionality as of the writing of this post. Fortunately, there are at least two ways of handling this situation.

One solution is to configure a wildcard subdomain, which redirects all requests for nonexistent subdomains to the actual, requested parent domain. So in our example, a request for images.cssresetr.com (which doesn’t exist) would result in the following:

The requested domain’s home page displayed for the nonexistent URL (better)

The URL remains as images.cssresetr.com in the address bar (even though that’s not what they are looking at)

This is an improvement, but we’ve still got to deal with that incorrect URL showing in the address bar. The way that I did this (and I’m sure there is an easier way) involves adding a little htaccess magic to the primary domain’s httpdocs directory:

Blam! That’s the magic right there. Once in place, this code will ensure that all requests for non-existent subdomains return the following:

The home page of the requested domain (cssresetr.com in our example)

The URL of the requested domain (i.e., (http://cssresetr.com/) displayed in the address bar

And best of all is that real, existing subdomains resolve as normal/expected. For my setup, this is the ideal functionality for setting up righteous canonical URLs and subdomains on Plesk/(mt). Remember to test like the dickens, and please let me know if there is a better way to do this! Thanks.

Check it out

Comments

So great, and thank you for sharing. I’ve been thinking about moving to DV on MediaTemple for sometime now, and so your sharing your experience is great. I hadn’t even thought that I’d need to do this, and you’ve explained how to once I do jump in. Thanks again.

2 for 2 on awesome articles. We always encourage customers, with write ups like these, to add to our wiki articles. If you ever have the time, we’d love to see this added to our library. Thanks again for the support, and feel free to let us know if you need any help.

This is a well timed post. I just created a new website and Google Webmaster Tools mentioned that I wasn’t utilizing URL canonicalization. I tried accessing my site with and without WWW (I prefer with) and was always redirected properly. I also noticed WordPress had already wrote what I thought was the necessary redirect in the htaccess file, but I added your “enforce www prefix” script to the file. I’ll see in a couple days whether or not Google is satisfied.

After a quick browse through your site and reading this helpful article, I’m certainly adding it to my bookmarks. Thanks Jeff!

Jeff – thanks for the great write up. I was similarly in the process of doing the items above but ran into another issue I’m hoping you’ve found a solution for. Ultimately, it appears Media temple has something built into their apache configuration which takes every subdomain literally and regardless of what is listed within the .htaccess file, it will seek out an actual directoy. I am trying to direct customers to http://(wildcard).site.com and have the URl automatically redirected to http://site.com?ID=(wildcard).

nothing I have found so far can accomplish this. Any luck from your end?

Enable www – This is the trick: even if you don’t want to use the www prefix, you need to enable it before canonicalizing your URLs. So, for each of your domains, click on the “Domain Administrator” button and put a checkmark in the “www” box (near the top of the options list).
Where is the Domain Administrator button. Can find it anywhere…

Books

Links

About the site

Perishable Press is the work of Jeff Starr, professional developer, designer, author, and publisher with over 10 years of experience. Check out some of Jeff's books and projects, follow on Twitter, or learn more »

Fun fact: Perishable Press has been online since 2005, and now features over 700 articles and more than 11,000 comments. More stats »