Thanks for your reply, Peter, however the main problem is all the links that already exist in the content of about 1,500 pages. I was hoping to find a solution that would deal with all those existing links as well as links in new content, without the content editors having to learn something new when a link is inserted into content.
I think I've found something that works, although it requires running an update script on the database to modify all the existing content, and then teaching the editors what they would need to do from now on when creating new content.
- Add a dynamically created
<base> tag as the first item in
<head> of the master template which sets the base url. So, for example, when the page is accessed via the main site, the base tag would be (eg)
<base href="https://thesite.com/" />. If, however, the page is accessed via the "Icecreams by Ivy" section of the site, the base tag would be
<base href="https://thesite.com/icrecreams-by-ivy/" />.
- Update ALL content and replace "~/" with "" where the content IS NOT like "~/getmedia" or "~/getattachment" - ie, update all links to pages, removing the prefixed "~/"
- Whenever a NEW link is inserted into a content area by an editor, always use the Insert/Editor Link button on the toolbar (which they already do, anyway), navigate to the relevant page, and then manually DELETE the prefixed "~/" that is displayed in the URL textbox on the Insert link dialog BEFORE they click the "Save & Close" button.
We've got to do a lot of testing before any of this is deployed live, but so far for everything we've tested appears to be redirecting correctly.