My provider let me to register thrid level domain name, as aliases of www.satollo.com. So, is a register an sexy.satollo.com it works like www.satollo.com.
Obviusly, I want the sexy.satollo.com to show the content of the subfolder "sexy" in my web space. With a simple .htaccess it is possible to go for that.
The tricks uses the mod_rewrite of apache (I think every hosting provider gives access to this apache module). This lines are enough:
RewriteCond %{HTTP_HOST} sexy.satollo.com
RewriteRule ^(.*)$ sexy/$1 [L,QSA]
inserted in an .htaccess in the main folder of the web space. When a request is made with sexy.satollo.com as host name, it will be rewritten adding the folder name before the file requested.
The mod rewrite works in this way:
- apache receives a request, mado of an uri (/test/index.php - as the user write it in the browser)
- apache tries to solve this request in a folder and a file on the file system
- if it finds a corresponding folder (test in our example) it will look inside for an .htaccess to be processed
- if no .htaccess is found in the folder, it goes up in the hierarchy to the web space root to find a valid .htaccess
- if no one is found the file index.php is served otherwise the .htaccess will be processed
- the .htaccess can have some "rewrite rules" that transform the original request in something different or bette in a different file name to be served
- the cicle restart
So a call like www.satollo.com/test/index.php will be resolved to /maindir/test/index.php. A call to sexy.satollo.com/test/index.php, will be resolved in /maindir/test/index.php, but the .htaccess in the main dir (pay attention no .htaccess has to be present in the test folder...) transform it in /maindir/sexy/test/index.php.
But, you know, duplicated content is a problem. A call to www.satollo.com/sexy/test/index.php is still valid and results in the same content as sexy.satollo.com/test/index.php.
May be no one konw anything about www.satollo.com/sexy/test/index.php, but to be totally secure, you can add a specific .htaccess in the sexy folder with this content:
RewriteBase /sexy/
RewriteCond %{HTTP_HOST} www.satollo.com
RewriteRule ^(.*)$ http://sexy.satollo.com/$1 [R=301,L,QSA]
Any request like www.satollo.com/sexy/test/index.php will be REDIRECT to sexy.satollo.com/test/index.php and the process starts again.
Other articles: Hyper Cache 1.2: more bugs than features?, How to Perform a Reflexology Foot Massage Explained in a Video, Bra World: All We Need to Know, Tomcat Shared Lib Class Loader and Privileged Context Attribute