Selecting a siteaccess using host or URI-based matching

As we saw in the first chapter, eZ publish can work using host or URI-based access.

Using the wizard, we selected the URI access method. This can be changed, if necessary, in the global override for the site.ini configuration file: /settings/override/site.ini.append.php. The behavior of the siteaccess system is controlled by the MatchOrder setting within the [SiteAccessSettings] block.

URI

This is the default setting for the MatchOrder directive, and is set by the setup wizard. When this access method is used, the name of the siteaccess that we want to use has to be the first parameter that appears after the index.php part of the requested URL.

For example, the following URL will tell eZ publish to use the panel siteaccess: http://packmediaproject/index.php/panel. If we want to use the ita siteaccess, then the URL that we have to call will be http://packmediaproject/index.php/ita. If nothing is used in the last part of the URL, then the default siteaccess will be used.

Setting the default siteaccess

The default siteaccess is defined by the DefaultAccess setting within the [SiteSettings] section. To change it, we have to open the /settings/override/site.ini.append.php file and make the changes highlighted here:

[SiteSettings]
DefaultAccess=ita
[SiteAccessSettings]
MatchOrder=uri

The URI access method is very useful for the development/preview stage where changing the DNS server isn't very easy.

Host

The host access method makes it possible to map different host/domain combinations to different siteaccesses. This access method requires the configuration of the server and DNS (not eZ Publish). The DNS server must be configured to resolve the desired host/domain combinations to the IP address of the web server, and then the web server must be configured to trigger a virtual host configuration (unless eZ Publish is located in the main document root). Once these settings are configured properly, eZ Publish can be set up to use different siteaccesses based on the host/domain combinations of the incoming requests.

The following example shows how to set up /settings/override/site.ini.append.php in order to make eZ Publish use the host access method. In addition, it reveals the basic usage of the host matching mechanism.

[SiteAccessSettings]
MatchOrder=host
HostMatchType=map
HostMatchMapItems[]=www.packmediaproject.com;eng
HostMatchMapItems[]=it.packmediaproject.com;ita

The example above tells eZ publish to use the eng siteaccess, if the requested URL starts with www.packmediaproject.com. If the requested URL starts with it.packmediaproject.com, the Italian version of the site will be used.

In the same way, we can configure HostMatchMapItems to use the admin panel and other languages. Using the host configuration is useful if we don't want to make the backend subdomain public, but want to make it internal to our network, or to support those sites that want to differentiate the languages instances with a dedicated subdomain.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.172.132