Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 used Apache's virtual host for a ton of subdomains for, where each twitter username is a subdomain, like <username> Problem is ... subdomains can't have underscores! :)

Now I've restructured the site, I want to permanently redirect all users that are going to the subdomain to the path:

<username> to the path structure<username>

e.g. to

Ideally I'd like to achieve this nearly in the Apache httpd.conf <VirtualHost> stanza instead of writing bits into /srv/www/

share|improve this question

Something like this would work:

<VirtualHost *:80>
    ServerAlias *
    DocumentRoot /var/www/localhost/htdocs/
    Include /etc/apache2/vhosts.d/default_vhost.include

    <Directory "/var/www/localhost/htdocs">
        Order allow,deny
        Allow from all

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^([^.]+)\.greptweet\.com [NC]
    RewriteRule ^(.*)$ [R,L]

share|improve this answer

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.