eZ Community » Forums » Setup & design » How to redirect /x to...
expandshrink

How to redirect /x to /defaultsiteaccess/x

How to redirect /x to /defaultsiteaccess/x

Sunday 05 February 2012 5:48:08 pm - 5 replies

Hi,

For a multilingual site (Community Project 2011.10), I am using in override/site.ini.append.php:

  DefaultAccess=fre

  MatchOrder=uri 

  URIMatchType=element

With this configuration:  

  www.domain.org/fre/ and www.domain.org display the fre siteaccess

  www.domain.org/eng/ displays the eng siteaccess

What is the proper way to redirect www.domain.org/ to www.domain.org/fre/? Currently I am using the following rewrite rules, as all my page aliases begin with a capital letter:

  # Redirect / to /fre

  RewriteRule ^/$ /fre/ [L,R=301]

  # Redirect /x to /fre/x if x begins with a capital letter

  RewriteCond %{REQUEST_URI} ^/[A-Z]

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

Thanks,

Mathieu

Monday 06 February 2012 9:03:14 am

There is a RemoveSiteAccessIfDefaultAccess=enabled if you don't need to show the default siteaccess. Then you would not need to rewrite. 

Monday 06 February 2012 9:55:57 am

Thanks. In my case, I would like to show the default siteaccess so RemoveSiteAccessIfDefaultAccess is set to disabled (default value). In fact without the rewrite rules, it seems to me that ezurl operator does not always include the fre siteaccess when a page is displayed without /fre (even if RemoveSiteAccessIfDefaultAccess=disabled). So some pages were accessible from 2 URLs www.domain.org/fre/x and www.domain.org/x. I would like to avoid this and always display fre siteaccess.

Mathieu

Monday 06 February 2012 10:08:40 am

Then you are stuck with rewrite rules IMO happy.gif Emoticon

Tuesday 07 February 2012 8:32:12 am

Thanks, I will keep the rewrite rules then.

Related post: http://share.ez.no/forums/setup-design/rewrite-rules-or-ini-settings-default-siteaccess

Mathieu

Tuesday 07 February 2012 3:08:58 pm

Personal feedback / note : when using RemoveSiteAccessIfDefaultAccess, take care of duplicate content. If your contents is accessible and referenced with and without /<siteaccess>, then you will have to use choose which URL should be the main one and add 301 redirections with these kind of rewrite rules.

The other solution is to enhance the canonical link feature provided in eZ Publish so that it can detect properly when the page is a duplicate or not (currently, it only works with multiple-located and translated contents).

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu