Friday 11 May 2012 7:57:50 pm - 12 replies
Hi there,
I am now working on eZ version 2011.12.
I need to set a rule where if my site is reached from a specified dns (which is pointing to the same ip) it should be addressed to another node as home page.
E.g.
mydomain.net -> Home
mydomain2.net -> Home2
So inside the .htaccess file I set a RewriteRule which is working for another eZ installation version 4.4 but somehow not for this one.
RewriteEngine On RewriteCond %{http_host} ^mydomain2.domainname.net [nc] RewriteRule ^index.php$ index.php/ita/Home2 RewriteRule ^index.php/eng$ index.php/eng/Home2 RewriteRule ^index.php/ita$ index.php/ita/Home2 [L] DirectoryIndex index.php
This block does exactly what it has to do in that 4.4 version, just had to move the DirectoryIndex at the bottom.
I tried everything but with no luck. I'd really appreciate if somebody could help me out!
Thanks!
Friday 11 May 2012 10:58:42 pm
Quote from Ivo Lukač :Hm, why don't you just have 2 siteaccesses with differetnt DefaultPage?
Hi Ivo, What I am trying to accomplish is using one installation for multiple sites purposes by setting the root's children nodes as if they are home pages for different domain names pointing to the same ip address.And so I need to set a rewrite rule which tells the site to open to a specified home page depending on the dns from which the call is made.I know it can be done because when I tested in a previous installation the URL www.domainname.it opens up to a node specified as in the rule pasted above.But now I can't have it work and I can't figure out why :/
Saturday 12 May 2012 12:49:20 am
I think Ivo is right, but you were also using HostUriMatchMapItems:
http://share.ez.no/forums/setup-d...and-one-ez-installation#comment62977
Saturday 12 May 2012 9:57:46 am
Quote from Lo' F. :Quote from Ivo Lukač :Hm, why don't you just have 2 siteaccesses with differetnt DefaultPage?
Hi Ivo, What I am trying to accomplish is using one installation for multiple sites purposes by setting the root's children nodes as if they are home pages for different domain names pointing to the same ip address.And so I need to set a rewrite rule which tells the site to open to a specified home page depending on the dns from which the call is made.I know it can be done because when I tested in a previous installation the URL www.domainname.it opens up to a node specified as in the rule pasted above.But now I can't have it work and I can't figure out why :/
I understand. But rewrite rules are awkward to deal with, it is simpler to set up another siteaccess with different DefaultPage and connect it with HostUriMatchMapItems in override/site.ini. Steven already provided you with an example.
Tuesday 15 May 2012 1:03:46 am
I have been looking through this MatchOrder stuff, which could have been a nice solution, but in my case is more a "node" thing than a "siteaccess".
In fact every node under the root constitutes a website with its own home page where each dns should point... that's the reason why I desperately need to make this rewriterule work.
As previously mentioned, those rules seem to work fine in a 4.4 installation.
Both the versions' settings/override/site.in.append.php (4.4 and 2011.12) has the same setting at these lines..
MatchOrder=uri
HostMatchMapItems[]
...
Again, your advise was really useful but if you could rather enlighten me to get to know what's the reason why those RewriteRule don't work in the latter version that would ...make my day!
Thanks indeed!
Modified on Wednesday 16 May 2012 1:16:15 am by Lo' F.
Tuesday 15 May 2012 8:21:35 am
Quote from Lo' F. :Again, your advise was really useful but if you could rather enlighten me to get to know what's the reason why those RewriteRule don't work in the latter version that would ...make my day!
Thanks indeed!
Eh, I am not a Rewrite expert
Are you sure you didn't change anything? Apache version? Something in virtualhost setup?
Tuesday 15 May 2012 10:26:00 am
This is also your friend:
RewriteLog /var/log/apache2/rewrite.log RewriteLogLevel 3
I don't see anything wrong with the rewrite rules off the bat, but you will be burned if someone adds a trailing slash. And, I hope you have these rules before the ezpublish rule that strips the index.php out - although with the [L] there it'll just ignore the ez rewrite rules...
Do you have some rules in the virtual host file and others in a .htaccess file? That might be tripping you up.
In any event, if you turn on rewrite logging you'll probably be able to see what's going wrong, just remember to turn it back off when you're done - it'll slow your site waay down.
Tuesday 15 May 2012 10:35:15 am
You should definitly go "ez-way" here and configure your mappings within ez and not apache.
So in settings/override/site.ini.append.php:
[SiteAccessSettings] ... AvailableSiteAccessList[] AvailableSiteAccessList[]=yoursite1 AvailableSiteAccessList[]=yoursite2 AvailableSiteAccessList[]=yoursite3 MatchOrder=host HostMatchMapItems[] HostMatchMapItems[]=yoursite1.tld;yoursite1 HostMatchMapItems[]=yoursite2.tld;yoursite2 HostMatchMapItems[]=yoursite3.tld;yoursite3
and then on settings/siteaccess/yoursite1/site.ini.append.php (assuming that node 1234 should be the homepage for yoursite1)
[SiteSettings] IndexPage=/content/view/full/1234 SiteName=Yoursite1 SiteURL=yoursite1.tld .. [SiteAccessSettings] PathPrefix=Sites/Yoursite1 ..
Best regards, Patrick
Tuesday 15 May 2012 10:37:59 am
take a step back and check the indicidual parts to make sure they work on the most basic level before mixing them together:
1 - lets rule out ezPublish:
For example: do you get expected results when you navigate directly to:
2 - All seems OK there? Then lets see what is happening with Apache rewrite in general
leave only this for your rewrites in your .htaccess file (or wherever else you are configuring it)
RewriteEngine on
RewriteRule ^/foo$ http://www.cheese.com [L]
navigate to: http://yourDefaultDomainName/foo
If foo does not bring you to cheese.com, then you are not rewriting on the Apache level (quite a few places to look at why this would be)
______________________________________________________________________
In the end, it still seems that after you get the rewrite working and confirmed that a separate siteaccess would be the cleanest solution. But I believe you addressed your rationale for that above.
Sunday 20 May 2012 9:15:04 pm
In a way or another your answers have given me valuable insights! ![]()
@Patrick
Your "ez-way" solution wasn't wrong. In fact might be a better alternative to what I had in mind...
(..so have to apologize to Ivo and Steven for not having given much credit to your advices at first ;P )
/settings/siteaccess/site1/content.ini.append.php
[NodeSettings] RootNode=62
/settings/siteaccess/site1/site.ini.append.php
[SiteSettings] SiteName=Site 1 SiteURL=xx.xxx.xxx.xx/site1 SiteURL=sitename.multisites.it/site1 IndexPage=/content/view/full/62 DefaultPage=/content/view/full/62 RootNodeDepth=2 MetaDataArray[author]=CWM MetaDataArray[copyright]=CWM MetaDataArray[description]=Site 1 web site MetaDataArray[keywords]=site 1, more keys [SiteAccessSettings] PathPrefix=Site-1 RequireUserLogin=false #RelatedSiteAccessList[] ShowHiddenNodes=false
/settings/override/site.ini.append.php
[SiteSettings] ... SiteList[]=site1 [SiteAccessSettings] ... AvailableSiteAccessList[]=site1 RelatedSiteAccessList[]=site1 MatchOrder=uri;host HostMatchMapItems[] HostMatchMapItems[]=sitename.multisites.it;site1
Just one more thing need to be done in the admin interface (otherwise the access to the page is not granted..)
User accounts > Roles and policies > Anonimous
Add new login policy to user for the new siteaccess
user > login > SiteAccess(site1)
So far seems a good way to go.
But .. ehi, ehi, ehi... about those RewriteRules I can't leave it like this... unsolved!
Yet, having problem with them and, at this point, wouldn't be nice just let it go so definitely I need to dig deeper...
@Ivo
..So am I ;P
@Steven
Thanks for the RewriteLog hint...
I called the two lines inside the /var/www/vhosts/domainname.it/conf/httpd.conf
RewriteLogLevel 9
RewriteLog /var/log/httpd/rewrite_logand created the rewrite_log file, assigning the writing permission to it, and of course restarted the server, but it does not seem to report any problem when I load the page with those rewriterules set...
@David
1 - Yes
2 - Here I can see it has a different behavior between the two installation:
4.4 .htaccess
RewriteEngine On
RewriteRule ^foo$ index.php/Site1 [L]
by entering the url http://xx.xxx.xxx.xx/foo it opens the Site1 page node
whereas the same at the 2011.12 as well as 2012.4 returns a kernel error 20, module not found.
:/
And so when I set my rewriterule I have exactly the same situation:
RewriteCond %{http_host} ^sitename.multisites.it [NC] RewriteRule index.php index.php/Site1 [L]
the 4.4 works but 2011.12 and 2012.4 don't.
The two default .htaccess from the two installations are different:
Here's the two of them with my rewriterule in it...
4.4 .htaccess:
# Copy this file to a new file called .htaccess in your eZ Publish root # to make the site more secure in non-virtualhost mode (index.php used in urls). # <FilesMatch "."> order allow,deny deny from all </FilesMatch> <FilesMatch "(^index\.php|favicon\.ico|index_treemenu\.php|\.(gif|jpe?g?|png|css|js|swf|html?)|var(.+)storage.pdf(.+)\.pdf)$"> order allow,deny allow from all </FilesMatch> # If you see "Forbidden" when trying to access root page of your site # without 'index.php' appended, uncomment the following "Files" section. # NOTE: replace "ezpublish-4.1.0" with base name of the directory # where your eZ Publish intallation resides. # e.g. base name of "/sites/ezpublish/ezpublish-4.1.0" is "ezpublish-4.1.0". #<Files "ezpublish-4.1.0"> # order allow,deny # allow from all #</Files> RewriteEngine On # Allow access to the index_treemenu.php file for a faster admin interface RewriteRule content/treemenu/? index_treemenu.php RewriteRule ^index_treemenu\.php - [L] # Uncomment the line below if you placed your favicon at the root of your # eZ Publish instance. It will then be served directly. #RewriteRule ^favicon\.ico - [L] # Uncomment the line below if you want you favicon be served from the standard design. # You can customize the path to favicon.ico by replacing design/standard/images/favicon.ico # by the adequate path. #RewriteRule ^favicon.ico design/standard/images/favicon.ico [L] RewriteRule ^design/standard/images/favicon\.ico - [L] # Uncomment the line below once you set up the right robots.txt file # In that case remember to also modify the FilesMatch rule abov # More info here http://en.wikipedia.org/wiki/Robots.txt #RewriteRule ^robots\.txt - [L] # Uncomment the line below in case you are using # Platform for Privacy Preferences Project ( P3P ) related files. # In that case remember to also modify the FilesMatch rule above # More info here : http://en.wikipedia.org/wiki/P3p #RewriteRule ^p3p/(.+)\.xml - [L] RewriteRule !(\.(gif|jpe?g?|png|css|js|swf|html?)|var(.+)storage.pdf(.+)\.pdf)$ index.php RewriteCond %{http_host} ^sitename.multisites.it [nc] RewriteRule ^index.php?$ index.php/Site1 [L] DirectoryIndex index.php
2012.4 .htaccess:
# Copy this file to a new file called .htaccess in your eZ Publish root # to secure your installation by turning on .htaccess based virtual host mode. DirectoryIndex index.php RewriteEngine On RewriteRule ^api/ index_rest.php [L] RewriteRule ^index_rest\.php - [L] RewriteRule ^([^/]+/)?content/treemenu.* index_treemenu.php [L] RewriteRule ^var/([^/]+/)?storage/images(-versioned)?/.* - [L] RewriteRule ^var/([^/]+/)?cache/(texttoimage|public)/.* - [L] RewriteRule ^design/[^/]+/(stylesheets|images|javascript)/.* - [L] RewriteRule ^share/icons/.* - [L] RewriteRule ^extension/[^/]+/design/[^/]+/(stylesheets|flash|images|lib|javascripts?)/.* - [L] RewriteRule ^packages/styles/.+/(stylesheets|images|javascript)/[^/]+/.* - [L] RewriteRule ^packages/styles/.+/thumbnail/.* - [L] RewriteRule ^var/storage/packages/.* - [L] RewriteRule ^info\.php$ - [L] # Makes it possible to placed your favicon at the root of your # eZ Publish instance. It will then be served directly. RewriteRule ^favicon\.ico - [L] # Uncomment the line below if you want you favicon be served from the standard design. # You can customize the path to favicon.ico by replacing design/standard/images/favicon.ico # by the adequate path. #RewriteRule ^favicon\.ico /design/standard/images/favicon.ico [L] RewriteRule ^design/standard/images/favicon\.ico - [L] # Give direct access to robots.txt for use by crawlers (Google, Bing, Spammers..) RewriteRule ^robots\.txt - [L] # Uncomment the following lines when using popup style debug. # RewriteRule ^var/cache/debug\.html.* - [L] # RewriteRule ^var/[^/]+/cache/debug\.html.* - [L] # Platform for Privacy Preferences Project ( P3P ) related files for Internet Explorer # More info here : http://en.wikipedia.org/wiki/P3p RewriteRule ^w3c/p3p\.xml - [L] RewriteCond %{http_host} ^sitename.multisites.it [NC] RewriteRule .* index.php/Site1 [L] RewriteRule .* index.php
... Why wouldn't it work the same way?!
Modified on Sunday 20 May 2012 9:25:03 pm by Lo' F.
Monday 21 May 2012 9:36:13 am
This:
IndexPage=/content/view/full/62
should make this:
RewriteRule .* index.php/Site1
unnecessary.
You should be already opening on the correct page - assuming that node 62 is the home for Site1.
Edit - fixed literal tagging.
Modified on Monday 21 May 2012 9:38:24 am by Steven E Bailey
You must be logged in to post messages in this topic!