views:

395

answers:

3

Hi all:

I was wondering how can I change the site URL of a SharePoint site that has already been created?

I can't do this since URL is a read-only field:

web.Url = "something";

Thanks.

EDIT:
Some clarification on my cumbersome explanation...

The URL I referred to was a SharePoint web site that was created programmatically in C#. E.g.

spWeb.Webs.Add(siteRelativeUrl, operationName, operationDesc, ...);

Now... suppose the website's URL is

http://localhost:12345/MyTopLevelSite/MyWebSite

I have since created a new version of MyWebSite. However I want to keep using the url name of MyWebSite while still preserving the old version of MyWebsite. So I want to programmatically rename the original MyWebSite to, e.g., MyOldWebsite, and then link the MyWebSite name to the new version that I have created.

My question is: is it possible to achieve this programmtically? If so, how?

Thanks.

A: 

I guess you cant change the URL of a site that has been already created. Instead you can try configuring alternate access mapping.

NLV
A: 

You have to use AAM (Alternate Access Mapping).

pointlesspolitics
+2  A: 

The URL of a subsite is created from the URL of the parent site and the name of the subsite - you need to set web.Name rather than the read only web.Url.

Alternate access mappings are for setting the hostname of a web application and do not affect the relative urls of sites within the web application.

Tom Clarkson
@Tom Clarkson: Thanks for your answer. I now know that I can use name instead of url to create a new site. However, I want to know whether it is possible to change the existing site's url to something else so I can use the existing site's url as the new site's url? E.g. do I need to run some sort of site/web update on the existing site to change its url? Thanks.
BeraCim
The same property works for renaming the existing site before you create the new one. something like: var oldweb = spWeb.Webs["MyWebSite"]; oldweb.Name = "MyWebSite2"; oldweb.Update();
Tom Clarkson