I've solved this by adding.htaccess file in htdocs folder of XAMPP. Here is the code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ [NC]
RewriteCond %{REQUEST_URI} ^/addonfolder/(.*)$
RewriteRule ^(.*)$ - [L,R=404]
Now domain.com/sub.domain.com has no access to sub.domain.com folder in htdocs, it retunrs 404 error.