views:

224

answers:

3

I've made a django site for a magazine, and it's found in mag.org/django-site. the old site is still at mag.org/httpdocs (hosted by mediatemple).

I would like it so that a hit to www.mag.org turns up the django site (as is currently the case, configured so in the conf file) while a hit to archive.mag.org serves the old site from httpdocs, that is, it's served by apache and not mod_python.

Is this possible to do through mod-rewrite, or mod-alias?

Thanks a million.

+2  A: 

You don't need either of those. Just set up your virtualhosts so that archive.* serves from httpdocs and www.* serves via mod_python (although I really, really recommend you serve Django via mod_wsgi).

For example:

<VirtualHost "*:80">
    ServerName www.mag.org
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE mysite.settings
    PythonOption django.root /mysite
</VirtualHost>

<VirtualHost "*:80">
    ServerName archive.mag.org
    DocumentRoot "/var/apache2/httpdocs"
</VirtualHost>
Daniel Roseman
You can add the appropriate log lines to the old site as well to determine how long you really need to keep the archive online.
wlashell
Thanks for the quick reply. I think this will work at webfaction, but unfortunately I'm stuck with a mediatemple dv server mediatemple, and I don't think virtualhost works the same way. directory structure is : var/www/vhosts/mag/mysite/ httpdocs/ conf vhost.conf subdomain/archive/ httpdocs conf vhost.conf maybe I can add [DocumentRoot "/var/www/vhosts/mag/httpdocs"] to /subdomain/archive/conf/vhost.conf.
Cody
+1  A: 

Yes, just use mod_rewrite, fe.:

Options +FollowSymLinks
Options +SymlinksIfOwnerMatch

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.mag.org$
RewriteRule ^(.*)$ http://mag.org/django-site [R=301,L]
RewriteCond %{HTTP_HOST} ^archive.mag.org$
RewriteRule ^(.*)$ http://mag.org/httpdocs [R=301,L]

Unfortunately the redirecion is visible to the user as far as I remember.

tkopczuk
A: 

DocumentRoot /var/www/vhosts/mag.org/httpdocs

was all I needed, sitting all alone in /var/www/vhosts/mag.org/subdomains/archive/vhost.conf

The virtualhost solution didn't work for mediatemple, because each vhost.conf is already delimited as a virtualhost, configured by plesk.

Thanks for the help everyone.

Cody