1

I have a Craft 3 multi-site site - / for the main site, /site1/ for site1, etc. I have a template templates/foo.twig, and /foo hits it for the main site, but /site1/foo does not hit it for site1. I think it should. What am I doing wrong?

I am trying to get case 4 of the Routing algorithm to work with multiple sites:

  1. Does the URI match a template?

Finally, Craft will check if the URI is a valid template path. If it is, Craft will return the matched template. Note: if any of the URI segments begin with an underscore (_), Craft will return a 404. Craft hides from direct access any template path segments that begin with an underscore.

1

I don’t think it has something to do with URI to template routing. It should just work once you have your sites setup correctly in Craft and in server configurations.

What you can do to test correct site setup in Craft is to request the page using the query string:

https://example.com/site1/?p=foo
  • Clearly something is set up wrong. https://example.com/site1/?p=foo works. The url for the site1 homepage is /site1/site1/. The .htaccess file is the unmodified original. This is running on vagrant/homestead, so there is nginx lurking in the background. I have set @web/site1/ for the base url in the control panel. – Marion Newlevant Feb 19 '18 at 17:18
  • Ahh good, routing to templates works! For your environmental issues you could have a look at other Nginx configs that work with Craft, e.g. nginx-craft. Your .htaccess isn’t read at all, it’s Apache only. – carlcs Feb 19 '18 at 18:51
  • Adding the nginx location rewrites fixed the template routing! Still have the /site1/site1/ problem, but progress. – Marion Newlevant Feb 19 '18 at 22:48
  • And the /site1/site1 thing was caused by setting the base URL to @web/site1/ instead of @web/, or better yet leaving it turned off. Do you want to write the nginx thing up as an answer, or shall I? – Marion Newlevant Feb 19 '18 at 23:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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