I have a domain (say example.com). There is a folder in root named freesites. For each subfolder of freesites (say sf) I add a subdomain (sf.example.com). In each subfolder there is a separate web application started with index.php file.
root (example.com)
|-- index.php
|-- .htaccess
|-- ...
|-- freesites
|-- sf1 (sf1.example.com)
|-- index.php
|-- ...
|-- sf2 (sf2.example.com)
|-- index.php
|-- ...
|-- sf3 (sf3.example.com)
|-- index.php
|-- ...
The problem: I don't want visitors to send requests as example.com/freesites/sf1/blabla. it doesn't work. I wish to redirect these requests to sf1.example.com/blabla. Furthermore I like to ban crawlers to do this type of requests.
What code I need in .htaccess and robots.txt?
Note: I redirected www to non-www in .htaccess now.
Edit1: .htaccess content is
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteBase /
RewriteRule ^freesites/([^/]+)/(.*)$ http://$1.example.com/$2 [R,L]
RewriteCond %{HTTP_HOST} ^www.example.com
RewriteRule (.*) http://example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
and it doesn't work