Problem with dynamic subdomains

#1
Hello,

I need to use dynamic subdomains, for multiple user session, so i have already a domain, is working well, when i use dynamic subdomain for exemple user1.domain.com i have a white screen with this error : Loading of the module at ... was blocked due to a forbidden MIME type ("text/html"). , The stylesheet ... was not loaded because its MIME type, "text/html", is not "text/css".

I use rewiteRules in OpenLiteSpeed like this :

# Redirect HTTP to HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# Exclude request to /api/ and static files
RewriteCond %{REQUEST_URI} !^/api/
RewriteCond %{REQUEST_URI} !\.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|otf|map)$ [NC]

# Handle dynamic subdomains in the form of user<number>.domaine.com
RewriteCond %{HTTP_HOST} ^user([0-9]+)\.domaine\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/api/
RewriteCond %{REQUEST_URI} !\.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|otf|map)$ [NC]
RewriteRule ^(.*)$ /index.html [L,QSA]

# Exclude the homepage (domaine .com) from being rewritten
RewriteCond %{HTTP_HOST} ^domaine\.com$ [NC]
RewriteRule ^(.*)$ - [L]

# Rewrite all other requests to index.html (for client-side routing in a SPA)
RewriteRule ^(.*)$ /index.html [L,QSA]


the domain.com working good, it's only subdomain, the front api is in React with Vite. I think it's a problem with static files but i don't find the solution...
Can you help me?

Thank you
 
#2
The rewrite rule section of "# Exclude request to /api/ and static files " and "# Handle dynamic subdomains in the form of user<number>.domaine.com " looks weird to me. As well as the "# Exclude the homepage (domaine .com) from being rewritten " section.

Is the subdomain site loadable if there are no rewritrules at all?
 
#3
Thank you to your answer, i tried to remove all rewriterules and the domain.com work good, but i have still a problem with this error: The stylesheet ... was not loaded because its MIME type, "text/html", is not "text/css" , so i haven't css in subdomain.
 
Last edited:
Top