<div dir="ltr"><div>Let's say I have two subsites, "category1" and "category2". If I try to link to an detail page in a different category, the generated URL's category does not change to match it.</div>
<div><br></div><div>For example, I have a page "/category1/index.html". From this page, if I link to a detail page such as /category1/1, everything is fine. The generated href points to category1/1. If I link to /category2/1, then the generated href ends up pointing to /category1/1, which isn't what I want.</div>
<div><br></div><div>Is this a bug? I searched the list of issues on GitHub and didn't find anything. I can submit an issue if this is unexpected behavior.</div><div><br></div><div>When I'm dealing with cms:link tags, I noticed that if I change the baseUri to "/", the category becomes correct again. Going back to my previous example, imagine I'm linking to pages from /category1/index.html. This is what happens:</div>
<div><cms:link>/category2/1</cms:link>  URL becomes ->  /category1/1</div><div><cms:link baseUri="/">/category2/1</cms:link>  URL becomes ->  /category2/1</div><div><br></div><div>This seems fine as a workaround when I'm using cms:link tags directly, but not when links are inserted through other means (for example, the WYSIWYG editor). I have no control over the baseUri value in those cases.</div>
<div><br></div><div>The only very hacky workaround I found was doing this in the JSP file itself:</div><div><br></div><div><span class="" style="white-space:pre">      </span>CmsObject cms = CmsJspElFunctions.convertCmsObject(request);</div>
<div><span class="" style="white-space:pre">    </span>String uri = cms.getRequestContext().getUri();</div><div><span class="" style="white-space:pre">     </span>try {</div><div><span class="" style="white-space:pre">              </span>cms.getRequestContext().setUri("/");</div>
<div><span class="" style="white-space:pre">            </span></div><div>... display WYSIWYG content here ...</div><div><br></div><div><span class="" style="white-space:pre">       </span>} finally {</div><div><span class="" style="white-space:pre">                </span>cms.getRequestContext().setUri(uri);</div>
<div><span class="" style="white-space:pre">    </span>}</div><div><span class="" style="white-space:pre">  </span></div><div>This worked, but it seems quite dangerous. Do you have any other suggestions? Or is this a bug that simply needs to be fixed? Thanks.</div>
</div>