0
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com
RewriteRule ^(.*)$ Subdomains/%1/$1 [L,NC,QSA]

I've tried that to make a subdomain for example, sub.domain.com show domain.com/sub How do I make it work? Do I need to enable some settings? Also, I'm trying to do this on a addon domain. Maybe the issue is because there is no .htaccess file attached to the domain? In that case, how do I give that domain a .htaccess file? And do I have to create a subdomain in cPanel in order for it to work? I already have a *.domain.com record.

Jack
  • 1,893
  • 1
  • 11
  • 28
  • Does this answer your question? [.htaccess rewrite subdomain to directory](https://stackoverflow.com/questions/10642426/htaccess-rewrite-subdomain-to-directory) – mylesthe.dev Jan 12 '21 at 22:01
  • _“how do I give that domain a .htaccess file?”_ - you don’t, instead you have the subdomain point to the same folder on the server, as the main domain. _“And do I have to create a subdomain in cPanel in order for it to work?”_ - most likely yes, otherwise your server won’t know what to do with request that contain the subdomain as host name. – CBroe Jan 13 '21 at 08:09

0 Answers0