charliedevelopment / craft3-fallback-site

Failing requests in a multi-site install can fall back to other sites, to prevent 404 errors from missing or disabled entries.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Redirect question

hatzipanis opened this issue · comments

Firstly thank you for developing this plugin. I'm currently using the trial version but I don't quite understand one thing. Here's my scenario:

I have two sites New Zealand (@web) and Australia (@web/au) and I have a Channel section Pages that is enabled for both sites. I have an entry Pricing (pricing) from this channel which is enabled for New Zealand and disabled for Australia. The fallback site for Australia is set to New Zealand.

With the Fallback Site plugin enabled, if I visit the Australian Pricing page (which isn't enabled) at @web/au/pricing, the URL resolves and shows the New Zealand page. If I disable the Fallback Site plugin the page 404's with the following message: Template not found: pricing.

Is this the correct behaviour? I had thought if the entry was disabled for a site it would redirect to the primary site so in our case it would redirect back to: @web/pricing.

If this is the correct behaviour, couldn't it be considered duplicate content?

@hatzipanis Thanks for reaching out about your use case! In this particular situation, if you would like it to redirect in the case of a fallback site's content being used, you could specify something like the following in your template:

{# The site being visited is different than the site of the content being used. #}
{% if craft.app.sites.currentSite != entry.site %}
	{% redirect entry.url 301 %}
{% endif %}

You are correct in that this is how Fallback Site behaves, and without any additional modification, such as the above, it would be considered duplicate content.

This way, any of the fallback site's content can be duplicated as needed on the visited site, but allows for the use of localized elements such as navigation. In these situations, the page in question could be marked as canonical to the fallback content's actual URL. If different behavior is desired, such as the example snippet above, Fallback Site allows you to detect this scenario and react accordingly.

Thank you @sbossarte and apologies for the slow reply. That's really helpful!

I will be purchasing 🤘