Featured Post

Update: SEO Issues - is it Penguin? Is it Panda? or is it me?

It was a little over a year ago that I posted the " SEO Issues - is it Penguin? Is it Panda? or is it me? " in which I detailed o...

Thursday, December 3, 2015

Domain, Subdomain and Subdirectory for SEO

I want a WordPress Blog for my Website

Whatever your business may be, chances are you have a website that is developed that promotes your business or, in some cases, is your business. More often than not, the website developed is managed by the development or engineering team, and to be able to add pages, edit content, or get any changes done for the website is a development process (whether it be a waterfall or agile project flow) that can take days, weeks, or even months to see any progress on. Even most content management systems reside on a server that doesn't allow for a blog like scenario that the marketing or public relations team can easily update quickly. This is where most companies will turn to WordPress. Wordpress is easy to install, fully customizable, easy to edit, easy to update, and is virtually impossible to screw up.

"You'll Have to Put It On a Subdomain" ...WRONG!

Bad for users - Bad for SEO

I have personally experienced the scenario of coming into a company that had already been through the discussion on setting up a WordPress website on another host than where the rest of the website exists. What the people involved at the time advised the company to do is set up a subdomain of their website and link to it in the top navigation. When users click the link in the navigation they go from www.thewebsiteinquestion.com to blog.thewebsiteinquestion.com. Sadly, when doing this, the blog will often look entirely different than the website. Not to mention that the content that is being written (often for SEO) is supporting just the subdomain and not the entire website.

A great example of a larger company using WordPress as a blog that looks completely different from the website is Twitter. Yes, the famous means of microblogging and staying connected with others through quick updates, images, videos, and links has a blog that resides on a subdomain and doesn't look anything like the website.
Not only is this a poor user experience, but the content on the subdomain is counted for the subdomain as it's own website, and does not support the main domain. One way to quickly rectify this for SEO is to have links from inner pages pointing from the subdomain to the website and from the website back to the subdomain where the pages all are similar to one another. Unfortunately, this just isn't the most ideal for the user especially when the website and the blog don't behave in a seamless way, and Google has been cracking down on linking both externally and internally. If not properly or carefully executed the website could inadvertently be flagged as trying to trick Google.

My recommendation, as with most white hat SEOs, is to have the blog reside in a subdirectory of the website rather than on the subdomain. In addition, the blog should look and act just as the website does.

Subdomains are aren't Fine for SEO

When you make the decision to have your WordPress blog reside in a subdirectory of your website you might get some push-back from developers or some of the people on the engineering (or possibly other) team. Working with one of my client's recently I was referenced the YouTube video by Matt Cutts (former Head of Spam Team at Google) in which he states that using subdomains for a website is just fine. My response was a bit of a lengthy one in which I cited a few trusted resources that supported the benefits that having a blog on a subdirectory have.

While most SEOs are familiar with the video of Matt Cutts, it is from 2012 (a few years ago). Rand Fishkin of Moz.com talked about this in his more recent video this year (2015):

He states: "You're asking, "Should I put my content on a subdomain, or should I put it in a subfolder?" Subdomains can be kind of interesting sometimes because there's a lot less technical hurdles a lot of the time. You don't need to get your engineering staff or development staff involved in putting those on there. From a technical operations perspective, some things might be easier, but from an SEO perspective this can be very dangerous."

In addition he says "I can't tell you how many times we've seen and we've actually tested ourselves by first putting content on a subdomain and then moving it back over to the main domain with Moz. We've done that three times over that past two years. Each time we've seen a considerable boost in rankings and in search traffic, both long tail and head of the demand curve to these, and we're not alone."

An article I have found that supports the subdomain question:
https://iwantmyname.com/blog/2015/01/seo-penalties-of-moving-our-blog-to-a-subdomain.html Blog traffic after switch to subdomain
...and yet another example of a site seeing improvement after changing to a subdirectory: ​http://www.bloggingflail.com/subdomains-vs-subdirectories-seo/

"I went from somewhere out of the top 100, and I know for a fact I wasn’t even in the top 200, to being number 57 in the SERP’s simply by changing from a subdomain to a subdirectory.  Everything else related to my site remained constant.​"

Championing the work through is usually 90% of the work when getting the WordPress blog into a subdirectory. As Rand mentions in his video it is much easier to just add a subdomain and point it to whatever is hosting the WordPress site. Unfortunately the implications of the WordPress blog residing on the subdomain rather than in a subfolder of the website is too great to take the easy way out. Using the above articles to help state your case and to continue to persevere through the challenges of those pushing back will get you to where you need to go, and the site will be successful as the end result.

Two Hosts - One Website

In the case where the WordPress blog has to be hosted on a different server and IP than the rest of the site, there is a process to take that will show a seamless website under the same domain. I have completed this task several times now and now have it down to a streamlined process (discussions to state benefits for SEO and all). I will tell you that if you do not have the technical background to understand some (or all) of this process, don't feel you should as it has baffled every developer, CTO, Engineer, and even some of the most genius of individuals I have worked with each time I do this.

Step One - Set Up WordPress Blog

Whether there is an existing blog that the website links to on a subdomain, or the blog doesn't exist yet, you want to set up a hosting account and install the WordPress blog under a subdomain. You will eventually point your new subdirectory to resolve to the subdomain, but for now you want everything on your WordPress blog to look and act as if it was a part of the website. A great example of a successful separate WordPress blog to website is the usedcars.com advice section. I worked for ADP managing the usedcars.com website SEO, SEM, Social, and Analytics from 2012 to 2014. Upon my first arrival the previous social media manager has worked with the agency to create a WordPress blog that the agency hosted and had designed. Unfortunately the WordPress blog looked nothing like the rest of the website, it resided on a server nowhere near ADPs servers, and it was in a completely different language from the rest of the site. You see, usedcars.com was/is hosted on Windows servers and written in .NET. WordPress is written in PHP using Apache.
This is what the usedcars.com homepage looked like in 2012This is the blog that the user would go to when clicking the link in the top navigation of the site. 
The site had a lot more issues going on with it that were bigger than the blog being on a subdomain could solve. However, the strategy of moving the blog to the site and it being a part of the site was on my list of things to do for SEO.

In this case the idea was to have a sort of "advice" section with car buying tips, ownership tips, and so on. So we decided to have the URL www.usedcars.com/advice be the new home page of the WordPress blog.

In this case the blog had so very little traffic to it (we're talking just a few hundred a day) that I started work on developing a custom theme for the WordPress blog that looked and acted much like the website.
The usedcars.com homepage
The WordPress blog with custom theme
Now that the blog that was hosted on blog.usedcars.com looked just like the website it was time to get the blog to show up when someone would go to usedcars.com/advice, and all of the pages within to work under that subdirectory.

Note: in the case for usedcars.com we wanted the WordPress blog to be hosted on ADP servers where the site could be managed by the company and be more secure. So the process of moving the files needed to take place before rewriting the URL. Since this is not a usual case, I am skipping that part and going straight to the URL rewrite.

Step Two - Rewriting the URL

When discussing the strategy of rewriting the URL I often find myself having to explain how the URL behaves to those that aren't quite technically inclined, and find myself having to correct those technically inclined that it is not a redirect.

When working with others and to help you understand what a rewrite is let's first cover the difference between the two.

Redirect vs Rewrite - What's the Difference?

When a user visits a website from a browser, that browser is hitting the server that the website resides on. The server will return a series of codes when that happens. Among those codes is the common "404" error you often see when you come to a page that doesn't exist, but more commonly is the "200" code that tells the browser it is okay and shows the page. The code we are talking about here is the "301" redirect code. This is telling the browser that the URL that is being accessed has moved to a completely different URL and then send the browser to that new URL. For example - click on this link: http://jennmathewsconsulting.com/that-301-redirect-goes-to/. Notice how the URL in the address bar changes to http://jennmathewsconsulting.com/301-redirect/

The redirect is what we call "client side" meaning that it is the browser on the computer of the user (or client) that creates the action, and the URL will always change in the browser as a result.

Other types of redirects:
  • 302 – Found 
  • 303 – See Other 
  • 307 - Temporary
The page request flow goes like this:
  1. The browser requests a page
  2. The server responds with a redirect status code
  3. The browser makes a second request to the new URL
  4. The server responds to the new URL and displays the page
When talking about rewriting the URL the behavior of the page is completely different. A rewrite is on what we call "server side" side meaning that the response happening when the page is requested is happening on the server. With a rewrite the browser is going to a URL and the URL stays bringing up the files that reside under a different URL, but stays the same. For example take a look at our client's blog we created for them under https://health2.drinkhint.com/. When you click through the links you will notice that the subdomain stays the same. This is the subdomain where the WordPress blog resides. Then go to https://www.drinkhint.com/health/ and you will see that the homepage and all the pages are exactly the same. The https://www.drinkhint.com/health/ URL is rewriting to the files at https://health2.drinkhint.com/ telling the user and the search engines that the blog for https://www.drinkhint.com/ is located in the subdirectory /health/.

The page request flow for this works as follows: 
  1. The browser requests a page
  2. The URL Rewrite then rewrites the URL and makes the request for the updated page
Everything is happening on the server side, and completely friendly for SEO.

How to Setup an SEO Friendly Rewrite
There are quite a few steps to get to this point where the URL is staying the same while clicking through the site and the CSS, JSS and Images from WordPress are pulling in correctly.

1) Relative URLs - The first step in rewriting is setting up WordPress to have relative URLs for images and stylesheets. A couple of recommended plugins can make this job an easy one.
  1. Relative Image URLs
  2. Relative URL
You may also need to add a few lines of code to your htaccess file in addition to the plugins, but these should get you to where you need to be.

2) htaccess Rewrite - The next step is to add a few lines of code to your htaccess file on the server that your main website is hosted. It won't work if you add it to the WordPress htaccess since the URL that will be rewritten is the main domain and if you're reading this chances are your WordPress blog is not on the same hosting as your main domain.

The code that needs to be added to the main domain's htacces on the server:

RewriteEngine On
RewriteBase /
RewriteRule ^blog/(.*)$ http://blog.yoursite.com/$1 [P]

Note that the "^blog/" part of the code is the subdirectory you would like your blog to be on and the "http://blog.yoursite.com/$1" part is the subdomain that your WordPress blog is currently on. My two examples I used earlier are the http://blog.usedcars.com (usedcars.com is on a .net platform and WordPress on Apache) andhttps://health2.drinkhint.com (drinkhint.com is on an apache eCommerce CMS and the WordPress is on another hosting platform). You can read more about rewrites at apache.org.

3) Redirecting Traffic - the next step you will most likely need to make is redirecting traffic to your blog. Each server is different, and every blog is different, so explaining this part in detail is a bit more complicated to cover all of the different scenarios. Apache servers have a means to set up a proxy.

This part is best left to the experts to manage for you, or you can always ask myself and my team to help you through the process since we have done it a few times we can usually determine what steps need to be taken fairly quickly, or troubleshoot if needed.

4) WordPress General Settings - Lastly you will want to check your WordPress Address (URL) and Site Address (URL) in your WordPress Admin General Settings. The URL doesn't always need to be set, but in some cases just the Site Address (URL) will need to be set to your subdirectory. Once again, I suggest having an expert help you with this part as you can run into issues with redirect loops and/or URLs just not working.

If you follow each one of these steps and you are still having issues, or you need help with getting through the steps, you can always count on myself and my team to help you through the process. As you can see, the impossible task of getting a subdirectory to rewrite on a completely different WordPress host on a separate server is doable.

No comments:

Post a Comment