URLs management

URL rewriting

Out of the box Jahia adds support for the improved SEO and user experience through various way of URL rewriting. This includes the following features:

URL mapping - allows providing mappings (user-friendly URLs, vanity URLs etc.) for frequently used or so called common resources, e.g. the last news page, company's profile, contact page, special offers etc. It also eases a web site or content migration activities, e.g. in case an old resource is replaced with the new one, but the URL locations should remain the same for preventing "broken links" for bookmarks and search engines.

Rewriting scope

It is important to understand the scope the different URL mappings or URL rewriting is applied to.

The one exception to all rules is the case where the server is accessed using a localhost domain names. This mode is targeted for development or quick prototyping phases and in such cases neither URL mappings nor SEO URL rewrite rules are applied to the URLs and all links remain unchanged.

The following table summarizes the applicable conditions for URL rules, in case a domain name other than localhost or an IP address is used:

Rules/Mode

Studio

Edit

Contribute

Render/Preview

Live

URL mappings (vanity URLs)

no

no

no

yes

yes

SEO URL rules

no

no

no

no

yes

Thus, in the Studio, Edit and Contribute modes the URL mappings and URL rewriting are not applied to make navigation and editing more consistent and predictable.

URL mapping

URL mappings are designed to provide language-dependent (if the site has multiple languages) custom URL (URL part) for a content resource.

Consider the following case, a HR department publishes new "Internship" page and would like to promote its URL in a more user-friendly way.

A HR manager adds the following URL mapping for the newly created internship page in English to be /internship and for the German (company site is multilingual with English and German versions) the /praktikum:

So the URLs for English and German versions of that page get "shortened" to:

i.e. the language and path of the page are replaced with the custom URL - /internaship, that was defined.

The rest of the URL - the "technical" part - can be automatically removed by activating SEO URL rewriting as described further in this chapter.

Another use case could be in case of a content migration from a previous version of the site platform, say using an ASP.NET CMS system, and keeping important links still working and not leading to 404 - "Page not found" errors.

The old page was accessible under e.g. "about.aspx" name. Creating for a new About Us page the following mappings:

Will still allow the old URL to /about.aspx to work, but a client-side redirect will be sent to the browser to /about, as this mapping is declared as the default one.

This follows the "single URL for resource principle" for the improved SEO. Nevertheless this redirection can be deactivated in digital-factory-config/jahia/jahia.properties (for versions, prior to 7.0.0.2 - WEB-INF/etc/config/jahia.properties) by setting the following flag to false:

# This parameter will control, that if vanity URLs exists for a node and if
# it has been accessed with a non-default vanity URL, we inform the client that
# the resource has permanently moved (HTTP status code 301)
permanentMoveForVanityURL = false

SEO URL rewriting

Jahia provides ready-to-use set of URl rewriting rules, located in the WEB-INF/etc/config/seo-urlrewrite.xml file, which are targeted to remove the "technical" part from the URLs to Jahia resources when rendering in Live mode.

The SEO URL rewriting rules are enabled by default and can be disabled by setting the following flag value to "false" in the digital-factory-config/jahia/jahia.properties (on versions prior to 7.0.0.2 - WEB-INF/etc/config/jahia.properties):

Additionally, the removal of /cms is achieved by activating the following setting in digital-factory-config/jahia/jahia.properties:

# If set to true, the /cms prefix will be also removed from URLs
# Note, this option is only valid if the SEO URL rewriting is activated,
# i.e. urlRewriteSeoRulesEnabled is set to true
urlRewriteRemoveCmsPrefix = true

Note that a flush of Jahia output caches is required after changing settings of SEO rewriting.

If both options are activated it allows in most of the cases to "reduce", for example, the following URL:

http://my.acme.org/cms/render/live/en/sites/global/home.html

to:

http://my.acme.org/home.html

assuming that the global site has the my.acme.org defined as a Web project host name in site properties and English is the default language of the site.

For non-default site-language, the language remains in the URL after rewriting. E.g. for a German home page of the same site the URL will be:

http://my.acme.org/de/home.html

Browser caching

Controlling browser caching

The client side cache for pages and static assets (CSS, JavaScript etc.) is controlled using URL rewrite engine rules, defined in the org/jahia/services/seo/urlrewrite/last-urlrewrite.xml file (packaged into WEB-INF/lib/jahia-impl-*.jar JAR):

Those rules can be extended to achieve fine-grained tuning of the caching strategy.

Forcing secure browsing for logged in users

There is an option for "forcing" a switch to an SSL (HTTPS protocol) for a user session, from login to logout. This allows sites with higher security concerns to force secured connections for logged in users.