Change from a URI to HOST based siteaccess

This article should help you change eZ publish from URI to HOST based siteaccess mapping.

It's easy to use URI based siteaccess in eZ publish, in development environment. The problem is that you usually get an extra long URL to your content like http://www.buildcms.com/index.php/site/services. Ideally, the URL should be http://www.buildcms.com/services.

This can be solved by doing some changes in your settings. It's recommenced to clean your eZ publish cache before you start this process to avoid conflicts with INI cache.

Update of Apache

You need to add rewrite rules to the Apache configuration file. This file is usually named httpd.conf and is only available for editing by administrators of your server. If you rent solutions from a shared hosting provider, or you have a system administration department in your organization, you should request them to update this information:

<VirtualHost *IP_ADDRESS*>
<Directory *EZ_PUBLISH_DIR*>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
RewriteEngine On
RewriteRule !\.(gif|css|jpg|png|js|asf|avi|wmv|swf|xsl|jar)$ /index.php
DocumentRoot *EZ_PUBLISH_DIR*
ServerName *DOMAIN_NAME*
ServerAlias *ADMIN_DOMAIN*
</VirtualHost>

Replace the following placeholders with your own values:

Placeholder

Description

Example

*EZ_PUBLISH_DIR*

Location of your eZ publish installation in the file system.

/home/domain.com/www

*IP_ADDRESS*

The ip address where you domain name is pointed to.

127.0.0.1

*DOMAIN_NAME*

The domain name in which your eZ publish installation should be publically presented on.

www.domain.com

*ADMIN_DOMAIN*

The domain name where you can access the administrative interface of eZ publish.

siteadmin.domain.com

Restart Apache to activate your new configuration.

PS: Remember to configure correctly both the public domain name and the administrative domain name in your DNS server.

Update of eZ publish

Open the settings/override/site.ini.append.php file in your a text editor. In this file you will find a block that is similar to this:

[SiteAccessSettings]
CheckValidity=false
AvailableSiteAccessList[]
AvailableSiteAccessList[]=site
AvailableSiteAccessList[]=siteadmin
MatchOrder=uri
HostMatchMapItems[]

In this example we have two siteaccesses available. “site” is the public site and “siteadmin” is the administrative interface.

To change this into a host based siteaccess match, you should edit this block of the site.ini.append.php so your code is similar to this:

[SiteAccessSettings]
CheckValidity=false
AvailableSiteAccessList[]
AvailableSiteAccessList[]=site
AvailableSiteAccessList[]=siteadmin
MatchOrder=host
HostMatchMapItems[]=*DOMAIN_NAME*;site
HostMatchMapItems[]=*ADMIN_DOMAIN*;siteadmin

Replace placeholders *DOMAIN_NAME* and *ADMIN_DOMAIN* in the same way as you did in step 1.

Save your changes and you should now be able to access your directly on host level.

License of this work

This work is licensed under the Creative Commons Attribution 2.5 License. This license lets you distribute, remix, tweak, and build upon our work, even commercially, as long as you credit us (BuildCMS) for the original creation.

License

Creative Commons Attribution 2.5 License

eZ publish™ copyright © 1999-2009 eZ systems as