<p>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.</p>

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

<pre><code>https://example.com/site1/?p=foo
</code></pre>

CC BY-SA 3.0
2018-02-19T17:18:29.597Z
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
CC BY-SA 3.0
2018-02-19T18:51:30.307Z
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](https://github.com/nystudio107/nginx-craft/blob/1.0.15/sites-available/somedomain.com.conf#L104). Your .htaccess isn’t read at all, it’s Apache only.
carlcs
CC BY-SA 3.0
2018-02-19T22:48:16.300Z
Adding the nginx location rewrites fixed the template routing! Still have the `/site1/site1/` problem, but progress.
Marion Newlevant
CC BY-SA 3.0
2018-02-19T23:04:00.727Z
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
CC BY-SA 3.0
2018-02-19T08:14:38.393Z
2018-02-19T08:14:38.393Z
carlcs
<p>I have a Craft 3 multi-site site - <code>/</code> for the main site, <code>/site1/</code> for site1, etc. I have a template <code>templates/foo.twig</code>, and <code>/foo</code> hits it for the main site, but <code>/site1/foo</code> does <strong>not</strong> hit it for site1. I think it should. What am I doing wrong?</p>
<p>I am trying to get case <code>4</code> of the <a href="https://github.com/craftcms/docs/blob/v3/en/routing.md" rel="nofollow noreferrer">Routing</a> algorithm to work with multiple sites:</p>
<blockquote>
<ol start="4">
<li>Does the URI match a template?</li>
</ol>
<p>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.</p>
</blockquote>

<routes>
Craft 3 multi-site route to template (no entry)
# Craft 3 multi-site route to template (no entry)

(Asked by: username_0 on 2018-02-18)

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](https://github.com/craftcms/docs/blob/v3/en/routing.md) algorithm to work with multiple sites:

> 4. 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.

**Tags:** routes

---

## 1 answers

### Answer by username_1 on 2018-02-19. Score: 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

> **Comments:**
> **username_0**: 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.  
> **username_1**: 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](https://github.com/nystudio107/nginx-craft/blob/1.0.15/sites-available/somedomain.com.conf#L104). Your .htaccess isn’t read at all, it’s Apache only.  
> **username_0**: Adding the nginx location rewrites fixed the template routing! Still have the `/site1/site1/` problem, but progress.  
> **username_0**: 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?  

---

