Subdomain vs. Subdirectory

 

Better blog.mydomain.com or mydomain.com/blog? Good question! If got asked this question again via Twitter on the weekend so therefore I decide to share my experiences:

 

Choose a subdomain, if….

- You plan to offer “different services” which are “logical separated” on one domain

- You are able to influence the subdomains without much effort

Example:

Blog.mydomain.com

Shop.mydomain.com

Forum.mydomain.com

 

Why?

If you choose to use subdirectories it is much more difficult to age these services. It is easier to create a CNAME entry and with that for example blog.mydomain.com leads to Tumblr Blog and not to a machine. Also it is possible to run the different sites on several machines (without Loadbalancer and so on).

 

Choose a subdirectory, if….

- You aren’t able to influent the subdomains (for example the whole applications-stack is installed at the customer but you don’t want the admin to unnecessary implement DNS-Settings

- The Application-Intern or the site is too small to create an own WebApp (like an Impressum for example)

 

What does Google think about this?

Here is a statement from a Google employee on YouTube.

 

And what about Stackoverflow?

I really like this answer:

Pro’s for subdomains:

· You can isolate configuration (for for example apache) per-domain.

· It will be easier to migrate parts of your application to other machines. Sub-directories won’t really give you this flexibility.

· Instead of having to use a $baseUri variable in every html template, you can just assume the root of the app is always /.

Cons:

· It will be much more annoying to quickly setup staging or temporary development environments. For every ‘app’ you will now need DNS of hosts-file entries and webserver configuration. With subdirectories you could drop the app in a directory, and go!

· If you do ever have the requirement to deploy your application on a different system where using / is because of some odd policy not possible, some rewriting might be in order.

My advice:

Make sure you can always do both, which will give you the best of both worlds. Every part of your app should have a configurable base uri that is always respected. As long as you make sure you can always go both ways, then who cares what you do? it’s just a url and it can always be changed.

 

But aren’t you using code-inside.de/blog yourself?

Well – when I created this blog some years ago I just didn’t know it better. The problem with a change would be that the old Links still have to work and I’m not sure how Google would take the news.

Therefore: think about this before you start Zwinkerndes Smiley

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

About the author

Written by

Learn more about our team.

2 Responses

  1. The use of subdomains also allows to formulate call to actions;)

    examples:
    visit.conde-inside.de
    explore.conde-inside.de
    experience.conde-inside.de

    Reply

Comment on this post

Recent Posts

  • image1929-570x143_thumb.png
    Create and validate own Json-Web-Tokens (JWTs)

    If you are interested in web authentication you probably have heard about JSON Web tokens (JWT). What is a JWT? Maybe I’m not using the correct security termination but however: JWTs are used to exchange claims between two systems. For example: You want to log on to a service (like Facebook, Twitter, etc.) and want […]

  • Micro-Optimization: how to shrink or „embed“ pictures

      I’m currently working on the “CodeInside Dashboard” and since the page structure isn’t that difficult it should be possible to fulfill all of Google Pagespeed or Yahoos YSlow recommendations. One of the rules was to optimize the 4 PNGs that are embedded on the page.   Before – without optimization: Below you can see […]

  • image1979-570x194.png
    Move to Windows Azure – VMs, Word Press Migration, DNS changes

    Since mid January this blogs runs on a WordPress installation in an Azure VM. Because I always thought that the subject is quite complicated this blogpost offers a view behind the scenes. Why this move? So far this blog (both German and English Version) runs on a hoster somewhere in Germany. The main problem with this […]

  • Windows Azure Active Directory – CRUD for users and groups

      Windows Azure Active Directory? If you are not informed about the subject I recommend you to have a look on this Azure Info site. Which resources are there? The Azure AD contains the following entities: - Users - Groups - Contacts - Roles Access to the directory or on the “directory graph” Although the […]

  • Introduction into SignalR 2.0 & Azure Website Websockets

      SignalR is an Open Source Framework for Real Time WebApps. The main problem with Real-Time in the web is the canal between Browser and Server. If you never had to deal with SignalR and this problem before here is a brief introduction:   The problem Traditionally the browser initiates the request to the server […]

Support us