@@ -37,6 +37,33 @@ RewriteRule \.php - [H=proxy:fcgi://php-%1.%2-debug:9000]
3737RewriteCond %{HTTP_HOST} ^([\w-]+)\.totara\d
3838RewriteRule ^ - [E=SITENAME:%1]
3939
40+ # Path-based multisite support (front-controller / v21+ sites only).
41+ # In addition to the subdomain form (mysite.totara83.localhost/foobar), allow the
42+ # path form totara83.localhost/mysite/foobar. This only applies when no sitename was
43+ # supplied as a subdomain; capture the first path segment as the candidate site.
44+ # Unlike the subdomain form, the /<site> prefix stays in the request URI so that
45+ # SCRIPT_NAME keeps the /<site> prefix once the request reaches the front controller.
46+ RewriteCond %{ENV:SITENAME} ^$
47+ RewriteCond %{REQUEST_URI} ^/([\w-]+)
48+ RewriteRule ^ - [E=PATHSITE:%1]
49+
50+ # v21+ front controller (path form): totara83.localhost/mysite/foobar.
51+ # Checked before the subdomain form below so a real path-based site takes precedence
52+ # over the base site's own front controller. Only matches when the candidate site has
53+ # a public/ webroot (front-controller / v21+ install). The host condition that captures
54+ # the php version is kept last so its %1.%2 backrefs survive into the RewriteRule.
55+ RewriteCond %{HTTP_HOST} !\.debug
56+ RewriteCond %{ENV:PATHSITE} ^.+$
57+ RewriteCond %{DOCUMENT_ROOT}/%{ENV:PATHSITE}/public/index.php -f
58+ RewriteCond %{HTTP_HOST} totara(\d)(\d)
59+ RewriteRule ^ %{DOCUMENT_ROOT}/%{ENV:PATHSITE}/public/index.php [QSA,L,H=proxy:fcgi://php-%1.%2:9000]
60+
61+ # v21+ front controller (path form, debug variant): routes to the debug PHP-FPM container
62+ RewriteCond %{ENV:PATHSITE} ^.+$
63+ RewriteCond %{DOCUMENT_ROOT}/%{ENV:PATHSITE}/public/index.php -f
64+ RewriteCond %{HTTP_HOST} totara(\d)(\d).*\.debug
65+ RewriteRule ^ %{DOCUMENT_ROOT}/%{ENV:PATHSITE}/public/index.php [QSA,L,H=proxy:fcgi://php-%1.%2-debug:9000]
66+
4067# v21+ (public/ directory exists): route all requests through the front controller.
4168# The [H=proxy:...] flag is set here (not only for .php URLs) so that requests like /
4269# or static-looking URLs are also processed by PHP-FPM via public/index.php.
0 commit comments