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.

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.)

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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]
share|improve this answer
    
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. –  user12158 Jul 22 '09 at 21:08

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

ServerAdmin webmasta@localhost.com
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.

share|improve this answer

Your Answer

 
discard

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.