08 April 2013 SEO, URL Robert Muehsig

Lieber blog.mydomain.com oder mydomain.com/blog? Gute Frage! Am Wochenende kam die Frage über Twitter wieder rein und hier mal meine Erfahrungen:

Nehmt eine Subdomain, wenn…

- ihr unter einer Domain “verschiedene Dienste” anbieten möchtet, die auch “logische getrennt sind”

- ihr leicht Einfluss auf die Subdomains nehmen könnt

Bsp:

blog.mydomain.com

shop.mydomain.com

forum.mydomain.com

Warum?

Wenn ihr diese Sachen über Subdirectories löst ist es schwieriger diese Dienste auszulagern. Man kann sehr einfach einen CNAME Eintrag machen und so verweisst z.B. blog.mydomain.com auf ein Tumblr Blog und nicht auf meine Maschine. Auch kann man sehr einfach die einzelnen Seiten unter anderen Maschinen laufen lassen (ohne Loadbalancer etc.).

Mit Subdirectories ist diese Sache komplizierter

Nehmt ein Subdirectory, wenn…

- ihr keinen Einfluss auf Subdomains habt (z.B. beim Kunden wird der gesamte Applikations-Stack installiert und ihr wollt den Admin nicht unnötig DNS-Settings einpflegen lassen)

- es Applikations-Interna oder die Seiten zu klein sind um eine eigene WebApp” daraus zu machen (Sowas wie ein Impressum vll.)

Was sagt Google zu dem Thema?

Ein Google Mitarbeiter hat sich dazu auf YouTube geäussert:

 

Und was sagt Stackoverflow?

Die Antwort find ich ziemlich gut:

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 /.
  • </ul>

    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.
    • </ul>

      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.

      Aber du nutzt selber code-inside.de/blog?

      Ja – der Blog ist schon einige Jahre alt und damals wusste ich es nicht besser. Problematisch bei einer Änderung jetzt wäre das die alten Links trotzdem noch funktionieren müssen und ich nicht genau weiss wie Google darauf reagiert.

      Daher vorher Gedanken machen ;)


Written by Robert Muehsig

Software Developer - from Saxony, Germany - working on primedocs.io. Microsoft MVP & Web Geek.
Other Projects: KnowYourStack.com | ExpensiveMeeting | EinKofferVollerReisen.de