<IfModule mod_rewrite.c>
RewriteEngine on
ErrorDocument 404 http://beta.suppletext.com/
# Skip rewrite if no hostname or if subdomain is www
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^(www|local|beta|forums). [NC]
RewriteCond %{REQUEST_URI} !^st-external/.* [NC]
# Extract (required) subdomain (%1), and first path element (%3), discard port number if present (%2)
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+).suppletext.com(:80)?<>/([^/]*) [NC]
# Rewrite to /subdomain/path
RewriteRule ^st-external/(.*) wiki/%1/st-external/$1 [L]
# Skip rewrite if no hostname or if subdomain is www
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^(www|local|beta|forums). [NC]
RewriteCond %{REQUEST_URI} !^st-external/.* [NC]
# Extract (required) subdomain (%1), and first path element (%3), discard port number if present (%2)
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+).suppletext.com(:80)?<>/([^/]*) [NC]
# Rewrite to /subdomain/path
RewriteRule ^st-system/(.*) wiki/%1/st-system/$1 [L]
# Skip rewrite if no hostname or if subdomain is www
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^(www|local|beta|forums). [NC]
RewriteCond %{REQUEST_URI} !^st-external/.* [NC]
# Extract (required) subdomain (%1), and first path element (%3), discard port number if present (%2)
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+).suppletext.com(:80)?<>/([^/]*) [NC]
# Rewrite to /subdomain/path
RewriteRule ^(.*) wiki/%1/index.php/$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>