Caution: This documentation is for eZ Publish legacy, from version 3.x to 5.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.

PathPrefix

Summary

Sets the hidden prefix that will be added to virtual URLs entered by users.

Usage

 

PathPrefix=prefix

Description

This directive sets the hidden prefix that will be added to virtual URLs entered by users. It is typically useful for multiple public siteaccesses that are used to display different parts of the content tree.

Consider an example siteaccess called "news" that should display content located under the "info" folder, which can be accessed at "www.example.com/news/info/". Normally, if an article called "conference" is located one level beneath the "info" folder, the URL to access this article will be "www.example.com/news/info/conference". If you specify "PathPrefix=info" in the "settings/siteaccess/news/site.ini.append.php" configuration file, the "conference" article will also be accessible through a shortened URL "www.example.com/news/conference" (in addition to the full URL mentioned above). This is because the system will automatically add the specified prefix after the siteaccess in the URL and look for the matching entry in the database table that stores the URL aliases. Since the URL alias table contains the "info/conference" entry, which points to the "conference" article node, this article will be displayed. The prefix is considered hidden because the URL in the browser remains as "news/conference".

With this configuration, only content located under the "info" folder will be accessible for the "news" siteaccess. To make other subtrees available for this siteaccess, you need to specify the corresponding prefixes using the "PathPrefixExclude" configuration array. For example, let's say that another folder called "articles" is located at the same level as the "info" folder in the content tree. If somebody enters "www.example.com/news/articles" as a URL, the system will automatically add the "info" prefix and attempt to access, without any success, "www.example.com/news/info/articles". To make the system properly handle virtual URLs in the "articles" subtree, you need to specify "PathPrefixExclude[]=articles" in the same configuration file. This will make all content located in the "articles" folder available for the "news" siteaccess.

If the "news" siteaccess makes use of multiple site languages, make sure you use the most prioritized one when setting the prefix for virtual URLs (see Example 3).

Note that the explanation above only uses URL aliases with lowercase Latin letters. In reality, folder names may contain different characters (spaces, uppercase letters, Unicode characters), while URL aliases are generated according to the "TransformationGroup" and "WordSeparator" configuration directives. By default, the system uses the "urlalias" transformation method and dashes as word separators. For example, if you create a folder called "Company news", it will get an auto-generated URL alias "Company-news" (stored in the database), while the actual URLs for site visitors can contain "company-news", "COMPANY-NEWS", "company-News" and so on. (Refer to "URL transformation rules" for more information.)

However, the "PathPrefix" directive is case sensitive, and when used, the prefix part becomes case sensitive when the full URL is accessed. In the example above, the prefix for the "Company news" folder must be specified as shown below:

PathPrefix=Company-news


If you specify "company-news", "COMPANY-NEWS" or "company-News" as a prefix, it will not work correctly.

With this configuration, if an article called "Conference" is located one level beneath the "Company news" folder, it can be accessed at both "www.example.com/news/Conference" (short URL) and "www.example.com/news/Company-news/Conference" (full URL). While the short URL is not case sensitive, the prefix part of the full URL is. This means that both URLs can contain, for example, "conference" instead of "Conference". However, if you replace "Company-news" with "company-news", "COMPANY-NEWS" or "company-News" in the full URL, it will not work any longer.

The "PathPrefixExclude" directive is also case sensitive. To make the content located in the "My articles" folder available for the "news" siteaccess, you need to add the corresponding URL alias to the PathPrefixExclude[] configuration array as shown below:

PathPrefixExclude[]=My-articles

In addition, it is recommended to have "Users" and "Media" listed in the "PathPrefixExclude[]" configuration array in order to make user accounts and media content available for this siteaccess through virtual URLs (otherwise only system URLs like "www.example.com/content/view/full/45/" will work for these items). In the URLs that point to user accounts and media content, the prefix part will become case sensitive.

If your site makes use of another URL alias configuration, URL aliases are generated differently than in the examples above, so be sure to use URLs appropriate for your setup. For example, if the "urlalias_compat" transformation method is used, only lowercase letters are allowed in URL aliases. (This also means that you'll have to specify "users" and "media" in the "PathPrefixExclude" setting in order to make user accounts and media content accessible.)

Examples

Example 1

Suppose you have two folders called "Books" and "Postcards" located right under the "Content" top level node. If you use two public siteaccesses called "bookshop" and "cards" for displaying content located in these folders, you will most likely have something like this in the "[SiteAccessSettings]" section of the "settings/override/site.ini.append.php" configuration file:

...
AvailableSiteAccessList[]
AvailableSiteAccessList[]=bookshop
AvailableSiteAccessList[]=cards
RelatedSiteAccessList[]
RelatedSiteAccessList[]=bookshop
RelatedSiteAccessList[]=cards
...

 

With this configuration, content located in both folders will be available for both siteaccesses. The "Books" folder can be accessed using URLs like "www.example.com/bookshop/Books/" and "www.example.com/cards/Books/". In the same way, the "Postcards" folder will be accessible through both "www.example.com/bookshop/Postcards/" and "www.example.com/cards/Postcards/".

Now, you can configure the "bookshop" siteaccess to only display content located in the "Books" folder. To do that, add the following lines to the "site.ini.append.php" configuration file of the "bookshop" siteaccess:

[SiteAccessSettings]
PathPrefix=Books

With this configuration, content located in the "Books" folder can be accessed using URLs like "www.example.com/bookshop/MyBook" and "www.example.com/cards/Books/MyBook". URLs like "www.example.com/bookshop/Postcards/MyPostcard" will not work any longer.

To configure the "cards" siteaccess to only display content located in the "Postcards" folder, add the following lines to the "site.ini.append.php" configuration file located in the "settings/siteaccess/cards" directory:

[SiteAccessSettings]
PathPrefix=Postcards

With this configuration, content located in the "Postcards" folder can be accessed using URLs like "www.example.com/cards/MyPostcard" and "www.example.com/cards/Postcards/MyPostcard". URLs like "www.example.com/bookshop/Postcards/MyPostcard" and "www.example.com/cards/Books/MyBook" will not work any longer.

Example 2

Let's have a look at the previous example assuming that the host access method is used instead of the default one. This means that eZ Publish is set up to use different siteaccesses based on the host/domain combinations of the incoming requests. In this case, the "[SiteAccessSettings]" section in the "settings/override/site.ini.append.php" configuration file will most likely contain the following additional lines:

...
MatchOrder=host
HostMatchType=map
HostMatchMapItems[]=www.books.example.com;bookshop
HostMatchMapItems[]=www.greetings.example.com;cards
...

With this configuration, the system will use the "bookshop" siteaccess if the requested URL starts with "www.books.example.com". The "cards" siteaccess will be used if the requested URL starts with "www.greetings.example.com". The "Books" folder can be accessed using URLs like "www.books.example.com/Books/" and "www.greetings.example.com/Books/". The "Postcards" folder will be accessible through both "www.books.example.com/Postcards/" and "www.greetings.example.com/Postcards/".

If you specify "PathPrefix=Books" for the "bookshop" siteaccess as shown above, content located in the "Books" folder will be accessible through the following URLs:

  • www.books.example.com/MyBook (short URL)
  • www.books.example.com/Books/MyBook (full URL)
  • www.greetings.example.com/Books/MyBook (full URL for the "cards" siteaccess)

URLs like "www.books.example.com/Postcards/MyPostcard" will not work any longer.

If you also specify "PathPrefix=Postcards" for the "cards" siteaccess, content located in the "Postcards" folder will be accessible through the following URLs:

  • www.greetings.example.com/MyPostcard (short URL)
  • www.greetings.example.com/Postcards/MyPostcard (full URL)

URLs like "www.greetings.example.com/Books/MyBook" will not work any longer.

Example 3

Let's say that your site content exists in English and French languages and you have two public siteaccesses called "gb" and "fr" with the following language configuration:

Siteaccess "gb"

Siteaccess "fr"

[RegionalSettings]
SiteLanguageList[]
SiteLanguageList[]=eng-GB
SiteLanguageList[]=fre-FR
[RegionalSettings]
SiteLanguageList[]
SiteLanguageList[]=fre-FR
SiteLanguageList[]=eng-GB

If a folder is called "Company" in English and "Compagnie" in French, it can be accessed using the following URLs:

  • www.example.com/gb/Company
  • www.example.com/gb/Compagnie
  • www.example.com/fr/Company
  • www.example.com/fr/Compagnie

While the first two URLs bring up the English version of the folder, the other ones will bring up the French version.

If you want the "gb" siteaccess to only display content located in this subtree, you need to add the following lines to the "settings/siteaccess/gb/site.ini.append.php" configuration file:

[SiteAccessSettings]
PathPrefix=Company

For the "fr" siteaccess, you would have to specify "Compagnie" as a prefix, since French is the most prioritized language for this siteaccess.

Example 4

Suppose that your site content exists in the Norwegian language. If you create a folder called "Ostehøvel" (Cheese slicer) located in the "Produkter" (Products) folder, the system will automatically generate a URL alias for it depending on which transformation method is used:

Transformation method

URL alias

urlalias (default)

Produkter/Ostehoevel

urlalias_iri

Produkter/Ostehøvel

urlalias_compat

produkter/ostehoevel

You can configure a siteaccess to only display content located in the "Ostehøvel" folder and skip the corresponding prefix in the URLs. If the default transformation method is used, this can be done by adding the following line to the "[SiteAccessSettings]" section of the "site.ini.append.php" file for this siteaccess:

PathPrefix=Produkter/Ostehoevel

If the "urlalias_iri" transformation method is used, the corresponding line will look like this:

PathPrefix=Produkter/Ostehøvel

If the "urlalias_compat" transformation method is used, you need to specify the prefix as shown below:

PathPrefix=produkter/ostehoevel

Frederik Holljen (31/03/2005 3:11 pm)

Julia Shymova (10/07/2008 9:04 am)

Frederik Holljen, Svitlana Shatokhina, Julia Shymova


Comments

There are no comments.