There are some properties for SPSite and SPWeb class using which we can get the URL values for the sites and webs. The two most used of these properties are - 'ServerRelativeUrl' and 'Url'
As a developer we use the values of the properties for writing some logic for satisfying the business needs. Whenever I used to write a OM code to use these properties, the first question which flashes in my mind - "What values are returned by these properties?". I immediately create a console application, and check the values returned by these properties and continue with the actual work. I have seen many other developers doing this. So, for a quick reference I prepared the below table which has the url values returned by these properties.
Some people may find this easy, but some (like me ;)) get confused when the sites have managed paths. These properties return the managed path if the site has one. Here goes the list
SCENARIO 1: A Site Collection (SPSite) without any managed path.
|URL : 'http://rams'|
|Url - http://rams/about ('about' is a sub site)|
This looks pretty simple. We get confused when sites are created using managed paths. Below are the samples values for site created with managed paths
SCENARIO 2: A Site Collection with a managed path (of type Explicit inclusion). For the below URL '/my' is the managed path
|URL : 'http://rams/my'|
|Url - http://rams/my/about ('about' is a sub site)|
SCENARIO 3: A Site Collection with a managed path (of type Wildard inclusion). For the below URL '/sites' is the managed path, and a site collection is created at '/blog'
|URL : 'http://rams/sites/blog'|
|Url - http://rams/sites/blog/about ('about' is a sub site)|