How to create a Redirect (URL Shortcut) to a Subsite in SharePoint?
Requirement:
We have a sub-site located at the URL – https://sharepoint.crescent.com/sites/marketing/regions/us/brandcenter/, and the requirement is to create a shortcut to this subsite. That is the URL shortcut: https://brandcenter.com should redirect to the above subsite.
Solution: To redirect to a subsite in SharePoint, let us use the IIS HTTP Redirect module. Follow these steps to redirect to a subsite.
Step 1: Create necessary DNS entries for your new host name
To begin with, create DNS entries for your new host (in my case: https://brandcenter.com). Based on your requirement, it could be a HOST-A Record / Forward Lookup Zone / CNAME, etc. For testing purposes, you can make an entry in your HOST file (located at: C:\Windows\System32\drivers\etc)
Step 2: Create New IIS Web Site:
- Go to IIS of your SharePoint Web front end server(s), Right-click “Sites” node create a new site by choosing “Add Web Site”
- Set the site name, Application Pool, Physical path accordingly. Host header as your new host name. Click on the “Test Settings” button to make sure your application pool account is able to access the virtual directory and authentication works as expected.
Step 3: Configure HTTP Redirect Module in IIS
Now, Open the “HTTP Redirect” module from the IIS Site you have created.
Enable the “Redirect requests to this destination” check box and enter the full URL of your subsite. Enable the “Redirect all requests to exact destination” check box also.
It is also possible to use Tokens in the URL, such as: $S = Path, $Q = Query String.
That’s all! Now, when a user hit https://brandcenter.com, they’ll be redirected to: https://sharepoint.crescent.com/sites/marketing/regions/us/brandcenter/ Its also possible to manage all these things using the command line: AppCmd .Refer: https://docs.microsoft.com/en-us/iis/get-started/getting-started-with-iis/getting-started-with-appcmdexe
PowerShell script to set IIS HTTP Redirect:
import-module webAdministration
#Set these variables: Site name and Redirect URL
$SiteName = "BrandCenter"
$RedirectURL = "https://sharepoint.crescent.com/sites/marketing/regions/us/brandcenter/"
# Set the redirect
Set-WebConfiguration system.webServer/httpRedirect "IIS:\sites\$siteName" -Value @{enabled="true";destination="$RedirectURL";exactDestination="true";httpResponseStatus="Found"}
This trick works on SharePoint 2007, SharePoint 2010 and SharePoint 2013 to redirect to subsite URL.