In htaccess, you can use the following rule to overwrite a subdomain in a subfolder:
RewriteEngine On #If the host is "sub.domain.com" RewriteCond %{HTTP_HOST} ^sub.domain.com$ [NC] #Then rewrite any request to /folder RewriteRule ^((?!folder).*)$ /folder/$1 [NC,L]
Line by line Explanation:
RewriteEngine on
In the above line, the server is prompted to enable URL rewriting.
RewriteCond %{HTTP_HOST} ^sub.domain.com$ [NC]
This line is a condition for the RewriteRule, where we map the HTTP host to the regular expression pattern. The condition says that if the host is sub.domain.com , then follow the rule.
RewriteRule ^((?!folder).*)$ /folder/$1 [NC,L]
The rule matches http://sub.domain.com/foo and internally redirects it to http://sub.domain.com/folder/foo .
Replace sub.domain.com with your subdomain and the folder with the name of the folder in which you want to point your subdomain.
starkeen Jan 18 '16 at 15:03 2016-01-18 15:03
source share