How to create multi subdomains with htaccess from folders, let's say I have my folders like this
/folder1/folder2/
and I want my address to be like thisfolder1.folder2.dominio.com
How to create multi subdomains with htaccess from folders, let's say I have my folders like this
/folder1/folder2/
and I want my address to be like thisfolder1.folder2.dominio.com
The first and second lines (Options and RewriteEngine) are used to enable url rewriting.
The following RewriteCond line will create a condition, which means that as long as the called url matches subdomain.mypage.com it will match and execute the following rule, otherwise it will simply skip it. [NC] is used to make it case-insensitive and the . they are used to escape the point since it is a special character of the rewrites.
The last RewriteRule line will collect any content that we send against that subdomain with (.*), that is, if we enter subdomain.mypage.com/algomas, the algomas part will be saved as a variable and we will include it later. The next part is the destination http://www.mypage.com/subfolder/ $1, the subfolder we want to send it to. The $1 is used to place the variable that we have said before, therefore when loading the subdomain that I have commented it would redirect it to http://www.mipagina.com/subfolder/algomas , so we could enter any subfolder and file that is typed into the browser automatically. Finally [L,NC,QSA] means:
I find it a bit complex to rewrite more than one subdomain, since it would be necessary to replace the . by /
For a single subdomain, it would suffice to:
finally, this would serve for domain of the type:
I hope it helps you
Cheers