Hi all
I think I need help with replacing string content that meets certain criteria.
Basically, I allow users to enter their own content via a WYSIWYG editor in a CMS. This content is then displayed on the site however when users create internal hyperlinks to other pages, the source code is as follows:
<a href="page-one/page-two">my link</a>
This creates massive problems as the user might be viewing the following page for example:
www.mysite.com/mypage/test
When the user clicks the above example link, the URL is redirected to:
www.mysite.com/mypage/test/page-one/page-two
instead of
www.mysite.com/page-one/page-two
I need to make sure any hyperlinks added to the source code are prefixed with a forward slash so the page is referenced from the web root.
Would a function that wraps around the output of my content achieve this and if so, how!?
Thanks for reading
kbc