requests to domain.com should be handled by main.php file on the html root
requests to sub.domain.com should be handled by another main.php file which is under “sub” directory (sub/main.php)
so to achieve this, i tried a htaccess file like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^sub\\.domain\\.com
RewriteCond %{REQUEST_URI} !^/images/
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteCond %{REQUEST_URI} !=/robots.txt
RewriteRule (.*) main.php [L]
RewriteCond %{HTTP_HOST} ^sub\\.domain\\.com
RewriteRule (.*) sub/main.php [L]
but ofcourse this is not working only domain.com rewrite is working properly, but if i try to call sub.domain.com, i get 404 error. it’s not going to sub/main.php
i just need this specific subdomain. i searched the forum but there are dynamic subdomain threads…
yes i know i can solve this by creating the subdomain from cpanel. but i need to solve it via htaccess.
maybe the answer will help more people out there…