rewrite
url
How to generate absolute links?
Question
A remote site must integrate a content view using AJAX. The various links inside the HTML produced must be absolute and not relative because of this
Answer
The only solution is to use URL Rewrite. Jahia implements Tuckey. For syntax please check http://tuckey.org/urlrewrite/manual/2.6/
To find where to place and name the XML containing the rewrite rules: https://www.jahia.com/fr/communaute/etendre/techwiki/gestion-des-urls/urlrewriting
Here is an example of urlrewrite.xml
that did the trick for this ticket:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.2//EN"
"http://tuckey.org/res/dtds/urlrewrite3.2.dtd">
<urlrewrite>
<outbound-rule>
<name>Append servername</name>
<note>Check if we need to add server name</note>
<from>^(((?!//).)*)$</from>
<to>%{scheme}://%{server-name}:%{port}$1</to>
</outbound-rule>
</urlrewrite>
Every links without //
will be prefixed with protocol://server-name:port/
Some restrictions and conditions must be added to this rule as it currently acts for the whole Jahia content.