Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

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.