Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

:: EDIT ::

How to setup wildcard subdomains and then rewrite the adress?

directory structure

/var/www/domain.com        // .htaccess with rewrite rules is placed here


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?

share|improve this question
could anyone help? –  clarkk May 25 '11 at 12:23

1 Answer 1

up vote 1 down vote accepted

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 to www.domain.com/page instead of www.domain.com/domain.com/page, which seems sensible, remove this block:

RewriteCond %{HTTP_HOST}        ^www\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI}      !^/domain\.com/ [NC]
RewriteRule ^(.*)$          /domain.com/$1 [L]
share|improve this answer
it's still the same.. you are redirected to domain.com/domain.com –  clarkk May 24 '11 at 22:23
I want to rewrite www.domain.com/domain.com/page to www.domain.com/page.. –  clarkk May 24 '11 at 22:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.