System Administrator Jahia 7.3 Jahia 8

One FQDN to rule them all


Is it possible to use one fully qualified domain name (FQDN) for multiple websites?


While Jahia supports one FQDN per website, it is possible to workaround that thanks to the use of URL rewrite rules at the front-end and Jahia levels BUT before going on this road, you should consider the following:

  • This kind of scenario is not supported by Jahia so it's not being tested for new releases or new products
  • Any new modification to the rewrite rules can have unforeseen side effects so it's strongly advised to have an automatic test suite to prevent any regression

The current scenario:

  • Two FQDNs: and
  • For each FQDN, three websites:
    • a "global" one, accessible through the URL https://<FQDN>/global/en/
    • two sub-sites, accessible through the URL:
      • https://<FQDN>/site1/en/
      • https://<FQDN>/site2/en/
  • The websites need to be configured this way:
    • each website of a company has:
      • a site key starting by the "company key" then with the site key
      • a server name starting by the site key then with the domain name. The server name has to be resolved, at least at the front-end level
  • HAProxy is being used at the front-end level (version 2.0.13-2)

Steps to follow:


  • Update your HAProxy configuration with the following configuration:
     log global
     mode http
     option httplog
     option dontlognull
            option  httpclose
     retries 3
            timeout connect 300
            timeout client  1200s
            timeout server  1200s
            option http-server-close
            option forwardfor
    frontend http_front
            bind *:80
            redirect scheme https code 301 if !{ ssl_fc }
    frontend https_front
            bind *:443 ssl crt /etc/haproxy/key_and_cert.pem
            reqadd X-Forwarded-Proto:\ https
            default_backend https_back
    #Production v1.0.16
    #dns list
    acl hdr(host) -i
    acl hdr(host) -i
    acl rootpath path_reg ^/$|^/global/$|^/global/..$
    acl language_en req.fhdr(accept-language),language(fr;en) -m str en
    acl language_fr req.fhdr(accept-language),language(fr;en) -m str fr
    acl forms path_reg ^/.*modules/forms/.*$
    #redirect back
    #redirects to company1 corporate website
    http-request redirect code 301 location if rootpath language_fr 
    http-request redirect code 301 location if rootpath
    #http-request replace-uri ^/([a-z]{2})/sites/company1_([^/]+)(/.*)$ /\2/\1\3 if
    #http-request replace-uri ^/([a-z]{2})/sites/company1_([^/]+)(/.*)$ /global/en/home/about/ if
    #redirects to company2 corporate website
    http-request redirect code 301 location if rootpath language_fr 
    http-request redirect code 301 location if rootpath
    #rewrites maybe use http-request set-path
    http-request replace-uri ^/(?!cms)(.*?)/([a-z]{2})/(.*) /\2/sites/company1_\1/home/\3 if
    http-request replace-uri ^/(?!cms)(.*?)/([a-z]{2})/(.*) /\2/sites/company2_\1/home/\3 if
    #set header for using right template
    acl site_company1 hdr(host) -i
    acl site_company2 hdr(host) -i
    http-request set-header shared-site company1 if site_company1
    http-request set-header shared-site company2 if site_company2
    ## Header sub-site
    http-request set-header sub-site %[capture.req.uri] if !forms
    http-request set-header sub-site %[hdr(referer)] if forms
    http-request replace-header sub-site ^https?://[^/]*(/[^/]*/[^/]*/.*)$ \1 if forms
    http-request replace-header sub-site ^/([^/]*)/?.*$ \1
    ## Header language
    http-request set-header sub-site-language %[capture.req.uri] if !forms
    http-request set-header sub-site-language %[hdr(referer)] if forms
    http-request replace-header sub-site-language ^https?://[^/]*(/[^/]*/[^/]*/.*)$ \1 if forms
    http-request replace-header sub-site-language ^/[^/]*/?([^/]*)/?.*$ \1
    ## Set the header host in order to activate the SEO for the correct website
    http-request set-header Host %[req.hdr(sub-site)] if !forms
    http-request set-header Host %[req.hdr(sub-site)] if !forms
    backend https_back
            compression algo gzip
            compression type text/plain text/css text/js text/xml text/javascript application/javascript application/json application/xml application/rss image/svg text/html
            server jahia1 check fall 1 rise 1 inter 2s 
            balance leastconn
     http-request set-header X-Forwarded-Port %[dst_port]
            http-request add-header X-Forwarded-Proto https if { ssl_fc }
     http-request add-header X-CLIENT-IP %[src]


  • Install a custom module (in our case multi-sites-rewriting) with two URL rewrite rules files (cf this generic documentation):
  • Set the property urlRewriteUseAbsoluteUrls to false in the file JAHIA_HOME/digital-factory-config/jahia/
  • Flush completely your Internet browser cache


Known issues:

  • SEO URLs are not working always as expected
  • Link to a page on another website does is incorrect