Setup VirtualHosts with Legacy URIs

From CobaltFAQs

Jump to: navigation, search

Backup the current Apache Config Files

Shell into the server (via SSH) as admin and become root

   su - 

Make a backup directory

   mkdir -p /etc/httpd/conf/backup

Make a backup copy of httpd.conf

   cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/backup

Get the httpd.conf and either download to local machine or edit in vi

Edit the httpd.conf File

First Enable VirtualHosts by adding this line to the file
NOTE: * will default to all IP addresses, if you have more than one replace * with the IP and if need by :PORT
Example: or

   NameVirtualHost *

Add the start of the first and default VirtualHost to the file
NOTE: * works the same way as above, Servername is the default server domain, ServerAlias is optional and DocumentRoot is the location of the default website

   <Virtualhost *>
   Servername www.domain.tld
   ServerAlias domain.tld *.domain.tld
   DocumentRoot /home/groups/home/web

Add the origional Qube config code from the srm.conf for the default server configuration next

   #Start the Rewrite engine
   RewriteEngine On
   RewriteCond %{HTTP_HOST}            ^([^:]+)
   RewriteRule ^/admin/?$              http://%1:444/login.php? [L,R]
   RewriteCond %{HTTP_HOST}            ^([^:]+)
   RewriteRule ^/cobalt/?$             http://%1:444/login.php? [L,R]
       RewriteRule ^/personal/?$           http://%1:444/login.php? [L,R]
   RewriteCond %{HTTP_HOST}            ^([^:]+)
   # redirection
   RewriteRule ^/groups/([^/]+)(.*)	/$1$2 [L,R]
   RewriteRule ^/users/([^/]+)(.*)	/$1$2 [L,R]
   # group rewriting
   RewriteCond %{HTTP_HOST}            ^([^:]+)
   RewriteRule ^/([^/]+)(.*)		-
   RewriteCond /home/groups/$1		-d
   RewriteRule ^/([^/]+)(.*)		/home/groups/$1/web$2 [L]
   # user rewriting
   RewriteCond %{HTTP_HOST}            ^([^:]+)
   RewriteRule ^/([^/]+)(.*)		-
   RewriteCond /home/users/$1		-d
   RewriteRule ^/([^/]+)(.*)		/home/users/$1/web$2 [L]
   # Cobalt administrative interface HTTP redirection
   RewriteCond %{HTTP_HOST}		^([^:]+)
   RewriteRule ^/login/?$		http://%1:444/login.php? [L,R]
   # Wizard redirection
   RewriteCond %{HTTP_HOST}		^([^:]+)
   RewriteRule ^/_wizard/?$		http://%1:444/base/wizard/start.html? [L,R]
   # end of admin interface mapping

Add the end of the VirtualHost. This takes care of the default website access.


Next we will create the new aliases for the server. Create your Aliases using the following format (add as many as you want, apache says more than 128 will start slowing traffic)
NOTE: * works the same way as above

   <Virtualhost *>
   Servername www.newdomain.tld
   ServerAlias newdomain.tld *.newdomain.tld
   DocumentRoot /home/users/newdomain/web

(Optional) If you wish to add support for the default path they had to follow on the origional server, add the following line to the previous block.
NOTE: This will allow www.newdomain.tld to work just like www.newdomain.tld/USERNAME so if your users explicity used the folder name in their paths, it will continue to work.

   RewriteEngine On
   RewriteCond %{HTTP_HOST}            ^([^:]+)
   RewriteRule ^/USERNAME(.*)	        /home/users/USERNAME/web$1

Save the file and upload if nessasary

Restart Apache

Restart the Apache Engine, the following command is a general restart command.

   /etc/rc.d/init.d/httpd restart


Personal tools