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.