Htaccess: Show homepage on an incorrectly selected subdomain

I need to display my own URL source when users mistakenly use the subdomain.

For example, if a user enters hames.domain.com instead of games.domain.com , then hames.domain.com should display the html source of the domain.com index.

Ps: I do not want an iframe or redirect, it needs to display the index of the main domain.

I tried under the code

 RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com$ [NC] RewriteRule ^%1/(.*)$ /$1 [L,NC] 
+4
source share
1 answer

Humm I am not a professional with htaccess, but if the user enters the wrong subdomain, he will receive a 404 error. Therefore, redirect it to your domain if he receives it.

ErrorDocument 404 domain.com

+1
source

Source: https://habr.com/ru/post/1445056/


All Articles