Apache server provide a very useful and handy mode-rewrite module, .htaccess. This file can be used to overwrite the server settings and redirect all requests from main domain to the target sub folder. For example, consider a domain ‘www.domainname.com’ which you want to redirect to a sub folder ‘subfolder’.