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

Possible Duplicate:
Redirect all subdomains to subfolders

I have a wordpress blog at the url http://www.orpheecole.com, I would like to setup 3 subdomains (cycle1, cycle2, cycle3) being redirected to their folders (1 subdomain = 1 wp blog, no multisite enabled)

The file tree looks like this:

/var/www/orpheecole.com/
/var/www/cycle1.orpheecole.com/
/var/www/cycle2.orpheecole.com/
/var/www/cycle3.orpheecole.com/

the following .htaccess try to redirect to /var/www/orpheecole.com/cycleX instead of its own directory, but id it's possible i'd rather redirect every subdomain to its own www folder. my sites-enabled file for main site is

# blog orpheecole
<VirtualHost *:80>
    ServerAdmin admin@orpheecole.com
    ServerName  orpheecole.com
    ServerAlias *.orpheecole.com

    DocumentRoot /var/www/orpheecole.com/

    <Directory /var/www/orpheecole.com/>
        Options -Indexes FollowSymLinks MultiViews
        Order allow,deny
        allow from all
    </Directory>

    ErrorLog /var/log/apache2/orpheecole.com-error_log
    TransferLog /var/log/apache2/orpheecole.com-access_log
</VirtualHost>

and the .htaccess located on /var/www/orpheecole.com/ looks like this

<IfModule mod_rewrite.c>

  RewriteEngine on
  RewriteCond %{HTTP_HOST} !^www.* [NC]
  RewriteCond %{HTTP_HOST} ^([^\.]+)\.orpheecole\.com$
  RewriteCond /var/www/orpheecole.com/%1 -d
  RewriteRule ^(.*) www\.orpheecole\.com/%1/$1 [L]

  # BEGIN WordPress
  RewriteBase /
  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
  # END WordPress

</IfModule>

I tried to remove wordpress directives but nothing change, and the rewrite mod is enabled and working.

share|improve this question

marked as duplicate by Ladadadada, mdpc, Iain Nov 16 '12 at 18:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
    
nice howto on your first comment, but I'd rather use them as full party website :) –  kitensei Nov 16 '12 at 10:39
add comment

1 Answer

up vote 0 down vote accepted

The best way to have subdomains in your apache is by using vhosts. Make a config file for each of your subdomains in sites-available and dont forget to enable it (example: a2ensite cycle1 )

here is an example for cycle1

# blog orpheecole
<VirtualHost *:80>
    ServerAdmin admin@orpheecole.com
    ServerName  cycle1.orpheecole.com
    ServerAlias *.cycle1.orpheecole.com

    DocumentRoot /var/www/cycle1.orpheecole.com

    <Directory /var/www/cycle1.orpheecole.com/>
        Options -Indexes FollowSymLinks MultiViews
        Order allow,deny
        allow from all
    </Directory>

    ErrorLog /var/log/apache2/cycle1.orpheecole.com-error_log
    TransferLog /var/log/apache2/cycle1.orpheecole.com-access_log
</VirtualHost>
share|improve this answer
add comment

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