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.

eZ debug

Timing: Jan 18 2025 16:11:15
Script start
Timing: Jan 18 2025 16:11:15
Module start 'layout'
Timing: Jan 18 2025 16:11:15
Module start 'content'
Timing: Jan 18 2025 16:11:16
Module end 'content'
Timing: Jan 18 2025 16:11:16
Script end

Main resources:

Total runtime0.8582 sec
Peak memory usage4,096.0000 KB
Database Queries67

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0081 588.1641152.6563
Module start 'layout' 0.00810.0043 740.820339.5078
Module start 'content' 0.01250.8443 780.3281637.6484
Module end 'content' 0.85680.0014 1,417.976616.1094
Script end 0.8582  1,434.0859 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.4099160.0002
Check MTime0.00130.1559160.0001
Mysql Total
Database connection0.00110.125910.0011
Mysqli_queries0.787891.7948670.0118
Looping result0.00080.0875650.0000
Template Total0.822895.920.4114
Template load0.00210.250120.0011
Template processing0.820695.620020.4103
Template load and register function0.00050.058310.0005
states
state_id_array0.00090.105910.0009
state_identifier_array0.00140.160420.0007
Override
Cache load0.00180.2048470.0000
Sytem overhead
Fetch class attribute can translate value0.00110.128040.0003
Fetch class attribute name0.00140.168270.0002
XML
Image XML parsing0.00540.625040.0013
class_abstraction
Instantiating content class attribute0.00000.001970.0000
General
dbfile0.00490.5745220.0002
String conversion0.00000.002140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 25
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs