Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a server running, which is a webserver as well as a DNS server. I've configured bind to accept any wildcard subdomain (*.mydomain.com). Now, I'd like for users to be able to use username.mydomain.com to view their profile page.

So far, I've succeeded to redirect username.mydomain.com to mydomain.com/username with the following lines in my Apache configuration file:

RewriteCond %{HTTP_HOST} !^www.* [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.mydomain\.com
RewriteRule ^(.*) http://mydomain.com/%1$1 [R=301,QSA,L]

When I type, for example http://rik.mydomain.com, it redirects to http://mydomain.com/rik, which is what I want, but the URL also changes in the address bar of my browser. Is there any way to redirect username.mydomain.com to a folder, and keep username.mydomain.com in the address bar?

I can't use a separate Apache configuration file for the subdomains, as there are to many subdomains (for each user).

Thanks in advance

share|improve this question

Try removing the "R=301," from your rewrite rule. That should prevent the server from telling the browser to change the displayed domain name.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .