Domain name-specific redirect
CONTENTdm site may have multiple URLs available, like the system-assigned domain name, a custom domain name, and a non-oclc.org 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.
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.