HostMatchMapItems - default siteaccess

Author Message

Clemens T

Tuesday 04 March 2008 3:24:05 am

Heya,

What I want to do is making sure that via .htaccess (preferably, or if necessary httpd.conf) the urls of my website will be going from this:
<b>
http://myhost.nl/index.php/en/services/
</b>
to
<b>
http://myhost.nl/services/
</b>

The technical manual of ezpublish speaks of a way to do this through <b>host access method</b>.

However, I can't figure it out on my own, so here I go:

I did the following in my override site.ini:

[SiteAccessSettings]
CheckValidity=false
AvailableSiteAccessList[]=en
AvailableSiteAccessList[]=nl
MatchOrder=uri;host
HostMatchType=map
HostMatchMapItems[]=www.myhost.nl;en

Now, what else is there left for me to do? Can I configure a .htaccess to work with this site.ini?

Thank a lot,
Clemens

André R.

Tuesday 04 March 2008 4:37:09 am

The magic word is 'vhost' / 'virtual host' / 'remove index.php', and there is plenty of other topics about it in the forums, her are some doc pages:

http://ez.no/doc/ez_publish/technical_manual/4_0/installation/virtual_host_setup
http://ez.no/doc/ez_publish/technical_manual/4_0/installation/virtual_host_setup/virtual_host_example

If you use URL matching for siteaccess, you need to turn on 'RemoveSiteAccessIfDefaultAccess' (site.ini) to remove the siteaccess name.

You might need to enable 'ForceVirtualHost' (site.ini) setting to force eZ Publish to use virtual host mode.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Clemens T

Tuesday 04 March 2008 5:55:03 am

Heya Andre, that helped a lot... I got it!

[SiteAccessSettings]
CheckValidity=false
AvailableSiteAccessList[]=en
AvailableSiteAccessList[]=nl
MatchOrder=uri;host;
HostMatchType=map
HostMatchMapItems[]=www.myhost.nl;en
HostMatchMapItems[]=myhost.nl;en
RemoveSiteAccessIfDefaultAccess=enabled
#did not enable forcevirtualhost, because then it breaks my index.php/mysiteacces/ bookmarks (and other people's) - index.php is not a module
#ForceVirtualHost=true

And the following .htaccess file in my root web folder:

Options +FollowSymlinks
RewriteEngine On
RewriteRule ^var/storage/.* - [L]
RewriteRule ^var/[^/]+/storage/.* - [L]
RewriteRule ^var/cache/texttoimage/.* - [L]
RewriteRule ^var/[^/]+/cache/texttoimage/.* - [L]
RewriteRule ^design/.* - [L]
#RewriteRule ^design/[^/]+/(stylesheets|images|javascript)/.* - [L]
#RewriteRule ^design/[^/]+/(stylesheets|images|javascript)/.* - [L]
RewriteRule ^share/icons/.* - [L]
RewriteRule ^sitemaps/.* - [L]
RewriteRule ^extension/[^/]+/design/[^/]+/(stylesheets|images|javascripts|javascript?)/.* - [L]
RewriteRule ^packages/styles/.+/(stylesheets|images|javascript)/[^/]+/.* - [L]
RewriteCond $1 !^index.php$
RewriteRule (.*) /index.php
DirectoryIndex index.php

This works great! Exactly what I wanted. My old links are still valid, but my new links are without the index.php and the default siteaccess.

Also in my templates I used the <b>|ezroot</b> operator instead of <b>|ezurl</b>. This gets rid of the index.php in the urls. (And because I didn't set ForceVirtualHost=true, this is needed.)

Kudos+1 for you hehe. When is there going to be a kudos system (or something similar) on ez.no?

Nehal Rupani

Tuesday 23 September 2008 11:58:33 pm

Hi Clemens,

I am trying to have nice url [Url Writing] in my ezpublish installation. i want to do it .htaccess way means i don't have permission to change httpd.conf file of apache. so i followed gudie line which you provided here.Here,I am puffing snippet which i change for

First,i made changes to settings/override/site.ini.append.php

CheckValidity=false
AvailableSiteAccessList[]=ezwebin_site
AvailableSiteAccessList[]=eng
AvailableSiteAccessList[]=ezwebin_site_admin
MatchOrder=host;
HostMatchType=map
HostMatchMapItems[]=nehal.onezero.no;eng
HostMatchMapItems[]=admin.nehal.onezero.no;ezwebin_site_admin
RemoveSiteAccessIfDefaultAccess=enabled

Second, I just created one htaccess file and then copied the content of HTACCESS_ROOT to htaccess as they suggested in doc.

RewriteEngine On
RewriteRule content/treemenu/?$ index_treemenu.php
RewriteRule index_treemenu.php - [L]
RewriteRule !\.(gif|jpe?g|png|css|js|html)|var(.+)storage.pdf(.+)\.pdf$ index.php
RewriteRule ^var/storage/.* - [L]
RewriteRule ^var/[^/]+/storage/.* - [L]
RewriteRule ^var/cache/texttoimage/.* - [L]
RewriteRule ^var/[^/]+/cache/texttoimage/.* - [L]
RewriteRule ^design/.* - [L]
#RewriteRule ^design/[^/]+/(stylesheets|images|javascript)/.* - [L]
#RewriteRule ^design/[^/]+/(stylesheets|images|javascript)/.* - [L]
RewriteRule ^share/icons/.* - [L]
RewriteRule ^sitemaps/.* - [L]
RewriteRule ^extension/[^/]+/design/[^/]+/(stylesheets|images|javascripts|javascript?)/.* - [L]
RewriteRule ^packages/styles/.+/(stylesheets|images|javascript)/[^/]+/.* - [L]
RewriteCond $1 !^index.php$
RewriteRule (.*) /index.php
cd /public_html/subdomains/nehal
cp .htaccess_root htaccess_root
DirectoryIndex index.php

 

André R.

Wednesday 24 September 2008 12:16:45 am

There is a small mistake in your walk true:
cp .htaccess_root htaccess_root
should be
cp .htaccess_root .htaccess

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Nehal Rupani

Wednesday 24 September 2008 4:24:40 am

Hi Andre,

Thanks for correcting small mistake.

Could Please let me know which in which templates files i need to change opreator from |ezurl to |ezroot. and can we create virtualhost using .htaccess file.

André R.

Wednesday 24 September 2008 4:39:00 am

Basically none, if you correctly setup your site in virtual host mode (ForceVirtualHost=true).
ezroot is meant to be use when you need a root url to a file, like {"var/ezwebin_site/cache/public/my_file.js"|ezroot} or to produce url to images in storage folder.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Nehal Rupani

Thursday 25 September 2008 4:44:58 am

Thank Andre

I have done URl Re-writing at my local server but that i have done with help of doing configuration in apache means it's not done .htaccess way which i need to do on live server.

I have asked server admin and they told thay have created virtual host for me now if i write rule in .htaccess then it's not reflecting and still old url appears. so i just want to make sure that is it possible to re-write url using .htaccess. i also given same rewrite rule which i gave during vhost configuration.

Many Thanks,
Nehal Rupani

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 31 2025 03:31:01
Script start
Timing: Jan 31 2025 03:31:01
Module start 'layout'
Timing: Jan 31 2025 03:31:01
Module start 'content'
Timing: Jan 31 2025 03:31:01
Module end 'content'
Timing: Jan 31 2025 03:31:01
Script end

Main resources:

Total runtime0.0232 sec
Peak memory usage6,144.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 588.1563151.2109
Module start 'layout' 0.00500.0035 739.3672220.6875
Module start 'content' 0.00850.0134 960.05471,009.9297
Module end 'content' 0.02190.0012 1,969.984441.9922
Script end 0.0231  2,011.9766 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002510.7167140.0002
Check MTime0.00114.7087140.0001
Mysql Total
Database connection0.00073.104210.0007
Mysqli_queries0.00239.816330.0008
Looping result0.00000.047310.0000
Template Total0.00093.710.0009
Template load0.00073.031210.0007
Template processing0.00020.699010.0002
Override
Cache load0.00051.940610.0005
General
dbfile0.00114.916480.0001
String conversion0.00000.027840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs