2

Is this possible? I want domain.com and sub.domain.com to point to the same Craft installation. If you go to domain.com you see the normal site. If you go to sub.domain.com you are presented with a password prompt then you see the same content as domain.com plus additional content

1 Answer 1

2

Welcome @bobartlett to StackExchange. Within your templates you could test what the current siteUrl is and only show content based on that. In addition if you are on sub.domain.com then test if the currentUser is logged in.

{% if siteUrl == 'sub.domain.com' %}
    {% if currentUser %}
        {# user is logged in #}
    {% else %}
        {# show login #}
    {% endif %}
{% else %}
    {# show normal content #}
{% endif %}

A second method would be to create multiple sites where the main domain goes to one site and the sub domain goes to the other. To keep your data the same on each site for most pages you would make sure to keep your translation settings for your fields configured to "Not translatable". For those pages you want different on the sub.domain.com site then just disable them for the domain.com site.

1
  • That is perfect! Many thanks
    – bobartlett
    May 11, 2023 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.