0

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.

kitensei
  • 123
  • 1
  • 4

1 Answers1

0

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>
Hex
  • 1,939
  • 10
  • 17