1
votes

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.

3

3 Answers

2
votes

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.

-1
votes

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

-1
votes

You have to use AAM (Alternate Access Mapping).