9

For this example we have two domains: http://www.example.com http://subdomain.example.com To use different templates for the subdomain, we can accomplished this with these steps: 1) Setup subdomain to point to a different directory on your server: Domain: /home/wherever/public_html Sub-domain: /home/wherever/public_html_subdomain 2) Copy your index.php ...


2

This question comes close but implementing with a subdomain doesn't work. It should work as long as you modify the rewrite rule to account for the subdomain: RewriteCond %{HTTP_HOST} !^foo\.bar\.com$ [NC] RewriteRule ^(.*)$ http://foo.bar.com/$1 [R=301,L] The code you posted was missing the ^ before foo\.bar\.com on the RewriteCond line. The purpose of ...


2

Ok so on this site: 1) I forgot that I'd moved the templates folder outside the craft folder for easy access with this in the index.php define('CRAFT_PLUGINS_PATH',realpath(dirname(__FILE__)./../plugins").'/'); 2) Making sure the assets sources url are changed is essential to get the site working.


2

I know you asked for a way to do this without using a redirect, but if it's handled server-side via twig, it would be transparent and virtually instantaneous: {% if siteUrl == "http://subdomain.site.com/" %} {% redirect 'subdomainFolder' %} {% endif %} You could also redefine the default 'index' template using indexTemplateFilenames in your config ...


2

Craft looks for partial matches to apply config settings (both general.php and db.php which means you can do things like: '.dev' => array( .. '.com' => array( .. Craft applies these settings for each match from the top of the file to the bottom. So in your case because you have the the production domain after your subdomain config it matches and ...


2

Sure it can. Craft 3 has multi-site support. And for using a subdomain, you don't even need that, just point that subdomain at the correct template URL (eg. forward blog.example.com to example.com/blog). The about single at example.com would just be your homepage.


1

I'd double-check your index.php files for all domains and make sure they're all using the correct handle in the define('CRAFT_SITE') code. Sometimes I copy/paste files between sites and forget to update the site-specific variables. I'd also make sure the Base URL for each site is correct in the settings. Also make sure the section your homepage uses isn't ...


1

As of this comment, Craft 3 is still in beta but you may want to consider it as your challenge sounds like the new Sites functionality may be a good fit. Sites, allow you to manage multiple websites and multiple languages in one Craft installation. You can find a longer discussion and some examples here: Managing Multiple Sites in Craft 3 – Sites and ...


1

Figured this out, the appId setting was the culprit: https://craftcms.com/docs/config-settings#appId If using this setting, you probably don't want to set it to something dynamic (as I was, e.g. md5($url)).


1

Are these two sites exactly the same, and this is just an alias? If so, you don't need any configuration, just point the DNS to the right place, and it'll work. If not, can you provide more details on what you're trying to achieve?


1

This is now fixed. The dynamic path to the new templates folder was wrong: define('CRAFT_TEMPLATES_PATH', realpath(dirname(__FILE__) . "/../templates_va").'/');


Only top voted, non community-wiki answers of a minimum length are eligible