Apache config for eZ hostname access & other apps?

Author Message

Mike Machnik

Friday 02 February 2007 7:22:27 am

Has anyone had any success running eZ in hostname access mode alongside other applications, on the same domain?

For example: eZ and apache are configured for hostname access for www.domain.com. eZ exists in the directory "/home/user1/public_html/ez" which is what DocumentRoot is set to.

However, you have another application located in "/home/user1/public_html/app2" that you would like to be able to access, for example at the URL "http://www.domain.com/app2".

Normally what happens is that eZ looks for the module "app2" and does not find it, and gives you a kernel(20) error.

I have tried adding Aliases to the VirtualHost in httpd.conf i.e.

<VirtualHost w.x.y.z>
ServerAlias domain.com
Alias /app2 /home/user1/public_html/app2
DocumentRoot /home/user1/public_html/ez
ServerName www.domain.com
...

But still getting the kernel error.

I've also tried this in "/home/user1/public_html/.htaccess"

RewriteEngine On
RewriteRule /app2$ /app2$1 [L]

and this in "/home/user1/public_html/ez/.htaccess"

...
<FilesMatch "(^app2$)|(index\.php|\.(gif|jpe?g|png|css|js|html)|var(.+)storage.pdf(.+)\.pdf)$">
...

No difference there either.

Thanks in advance for any help...

Kim Johansen

Monday 05 February 2007 12:01:16 am

Check apache error-log and rewrite-log to see whats happening.

You can find more about the vhost-configuration here: http://ez.no/doc/ez_publish/technical_manual/3_8/installation/virtual_host_setup

Try out Free eZ Publish 4.0 Trial Hosting for 14 days:
http://webdealhosting.com/ez-publish-trial-hosting

High quality eZ Publish Hosting since 2001!

Mike Machnik

Wednesday 07 February 2007 9:09:38 am

Thank you...the rewrite log did help. Here is what works now: add these three lines to the VirtualHost:

Alias "/test" "/home/user1/public_html/test"

RewriteRule ^/test/(.*)$ /test/$1 [L,PT]
RewriteRule ^/test$ /test/ [R=301,L]

I took out my .htaccess changes, not needed. I only needed the above three lines in VirtualHost.

Hope this helps someone else too...

Timmothy Green

Wednesday 07 February 2007 12:37:27 pm

I have used the following method to accomplish this:

Alias "/test" "/home/user1/public_html/test"

RewriteEngine On
RewriteCond  %{REQUEST_URI}   !^/test/(.*)$
    RewriteRule !(^/design|^/var/.*/storage|^/var/storage|^/var/.*/cache|^/var/cache|^/extension/.*/design|^/kernel/setup/packages).*\.(gif|css|jpg|png|jar|js|ico|swf|wmv)$ /index.php

This instructs Apache to apply the RewriteRule to the requested URL as long as it does not contain "/test/". It essentially bypasses the RewriteRule based on whatever condition you choose.

End result is the same but I thought I would share another option.

Automation Technologies, Inc.
http://www.ati4it.com

Linh Vu

Wednesday 07 February 2007 5:39:40 pm

Just throwing in my 2c...

I use the same method as Tim's, although the (.*) is not necessary and using a catch-all wildcard in regex is generally not recommended unless you want a wholesale redirection.

Mike's method works but is not safe both because of Apache's internal order of processing rules (Redirect, Alias, Rewrite and ScriptAlias - note: not in this order, just a list). You can easily run into problems if you rely on this, so it's best to be specific and tell ezPublish, via a RewriteCond, not to process those folders.

Here's my general ezPublish Apache config:

    ServerName example.com
    ServerAlias www.example.com admin.example.com

    RewriteEngine On
    # no-www
    RewriteCond %{HTTP_HOST} ^www.example.com$
    RewriteRule ^/?(.*) http://example.com/$1 [R=301,L]

    # eZ publish
    # Excluding custom app folders
    RewriteCond %{REQUEST_URI} !(^/app1|^/app2|^/app3) [NC]
    RewriteRule !(^/design|^/var/.*/storage|^/var/storage|^/var/.*/cache|^/var/cache|^/extension/.*/design|^/kernel/setup/packages|^/packages|^/share/icons).*\.(gif|css|htc|jpg|png|jar|js|ico|pdf|swf)$ /index.php [L]

If I had more time, I would write less code.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.