I Use Htaccess File to RewriteRule My Website Subdomains to relative files on my site. For example:
http://articles.mysite.com --> http://mysite.com/articles
I write this code :
RewriteCond %{HTTP_HOST} !^www.mysite.*
RewriteCond %{HTTP_HOST} ^([^.]+).mysite.*
RewriteRule ^$ ./%1 [L]
But When i Want Use This :
http://articles.mysite.com/some/some --> http://mysite.com/articles/some/some
Above code doesn't work properly and redirect me to 404 NotFound Page
Note: In another place of my .htaccess file i have RewriteRule ^some/(.*)$ ./some.php?id=$1 [L]
Just change your rule to:
RewriteRule ^(.*)$ /%1/$1 [L]
and add a condition to prevent looping:
RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} -d
So you have:
RewriteCond %{HTTP_HOST} !^www.mysite.*
RewriteCond %{HTTP_HOST} ^([^.]+).mysite.*
RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} -d
RewriteRule ^(.*)$ /%1/$1 [L]