:: EDIT ::
How to setup wildcard subdomains and then rewrite the adress?
directory structure
/var/www/domain.com // .htaccess with rewrite rules is placed here
/var/www/domain.com/_admin
/var/www/domain.com/_admin/tst
/var/www/domain.com/_files
/var/www/domain.com/_mysql
.htaccess
RewriteCond %{HTTP_HOST} ^(admin|files|mysql)\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/_(admin|files|mysql)/ [NC]
RewriteRule ^(.*)$ /_%1/$1 [L]
when you request http://admin.domain.com/tst
the adress is rewritten to http://admin.domain.com/_admin/tst
how to fix it so /_admin
is hidden?
The behaviour you report seems to follow your configuration closely. What is the expected result that you're not getting?
If you want to redirect
domain.com/page
towww.domain.com/page
instead ofwww.domain.com/domain.com/page
, which seems sensible, remove this block: