2

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?

  • hosted by mediatemple dv. httpd.conf is rewritten by plesk; httpd.conf access is limited to a single vhost.conf for each domain/subdomain.

  • a simple [DocumentRoot /var/www/vhosts/mag.org/httpdocs] in the [/mag.org/subdomains/archive/conf/vhost.conf] was all I needed.

  • now mag.org points to the django site being served by mod-python, while archive.mag.org points to the httpdocs folder, served by apache.

(I initially posted this at stack-overflow, but I think it's more suited for serverfault.)

2 Answers 2

1

Best way to do this is with two virtual hosts, one for www.mag.org, and one for archive.mag.org

<VirtualHost *:80>
    ServerName www.mag.org
    DocumentRoot /path/to/django-site
</VirtualHost>

<VirtualHost *:80>
    ServerName archive.mag.org
    DocumentRoot /path/to/httpdocs
</VirtualHost>

This answer on virtualhosts and aliases may be helpful to you.


Edit: It is possible to do this with mod_rewrite, if you really need to. If you have mod_proxy you can also proxy the re-write so that the address doesn't change in the user address bar.

DocumentRoot  /path/to/django-site
Alias         /archive/                    "/path/to/httpdocs/"
RewriteRule   ^archive\.mag\.org(.*)$      http://www.mag.org/archive$1 [NC,P,L]
1
  • thanks for the quick reply, but I don't think this will work at mediatemple. I'm using their dv container, and all domains contain their own vhost directory and vhost.conf file. I'll try it, though. Jul 22, 2009 at 21:08
2

You can do the following in your vhost.conf file:

ServerAdmin [email protected]
ServerName  a server name
ServerAlias a server alias
DocumentRoot /path-to-django-web/root
<Directory  /path-to-django-web/root >
    Options FollowSymLinks Indexes
    DirectoryIndex index.php index.html
    AllowOverride All
    Order allow,deny
    Allow from all

       <IfModule mod_rewrite.c>
               RewriteEngine On
               RewriteBase /

               #Do your rewrite magic here
       </IfModule>
       <IfModule !mod_rewrite.c>
               ErrorDocument 404 /index.php
       </IfModule>
</Directory>

That is the way MT DV's vhost loads custom vhost configuration, it does not need the VirtualHost tags since they are already loaded by the default VH configuration.

Remember to restart your server and to reconfigure your domain, check what are the options available on your server manager, in the terminal type the following:

$ /usr/local/psa/admin/sbin/websrvmng --help

Usually you will have to reconfigure vhost

After that restart apache

$ /etc/init.d/httpd graceful

That should do it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .