Skip to main content
OCLC Support

Domain name-specific redirect

CONTENTdm site may have multiple URLs available, like the system-assigned domain name, a custom domain name, and a institution domain name. Even though you may have specified only one of these domains as the canonical domain to be published in your sitemap.xml, it is possible that the other domains will find their way into people’s browser bookmarks or get added to search engine indexes. This is certain to happen if those alternate domains have ever been published publicly or used in CONTENTdm record metadata.

You can use a simple JavaScript customization to detect requests coming in on these alternate domains and immediately redirect them to your primary (canonical) domain. In the example code below, when users try to navigate to the system-assigned domain name, they are immediately redirected to the boutique domain instead.

Note that this example is not particularly sophisticated since it operates only at the level of the root hostname. This means that any URL parameters that might have been included in the original request will not be retained after the redirect. You could argue this is useful behavior to let users know they are using an incorrect base URL, but a better user experience would be to enhance the script to capture all request URL parameters and append them to the redirected target URL.