You were correct to use the /etc/hosts file, that solves the DNS end of the problem.
The problem now lies therein that mainsite.net is now served from /home/mainsite/public_html and the OP would also like to serve mainsite.net/username from /home/username/public_html
As I’ve never done something like this I wouldn’t know how to set it up (beside suggestion mass virtual hosting, which to me seems way over the top to solve this problem, so it’s not a good suggestion). David, your turn again
This is a DNS problem so look for your DNS settings to configure your newsite. I’m not sure where those are on a 'nix box so let Stomme poes (or ScallioXTX?) direct you there.
(you DID update your server’s hosts file, didn’t you?).
If you can’t tell, I’m pretty new to managing my server. So, no. I didn’t edit the hosts file. All the how to’s I found said I just needed to add a new vhost. How exactly should I edit it?
That still looks like it’s properly formatted (should not cause the server to not start). Comments, though:
<VirtualHost [COLOR="Gray"]{serverip}[/COLOR]:80>
DocumentRoot /home/mainsite/public_html
ServerAdmin david@mainsite.net
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
[COLOR="RoyalBlue"]# my test server is configured as follows:
#<Directory />
# Options FollowSymLinks
# AllowOverride All
# Order deny,allow
# Deny from all
#</Directory>
# Note that I was WRONG with my insistence that
# a space was required in the <Directory /> line
[/COLOR]
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
<Directory "/home/mainsite/public_html">
allow from all
Options +Indexes
RewriteEngine on
#RewriteBase /fbk/ctb
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_URI} ^/fbk/ctb/(.*)$
#RewriteRule ^(.*)$ /fbk/ctb/index.php?q=$1 [L,QSA]
[COLOR="Red"]RewriteBase /[/COLOR]
# I always comment on RewriteBase (when a mod_alias Redirect is not used)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>
ServerName mainsite.net
# The following should also give you the www'd version
[COLOR="RoyalBlue"]ServerAlias www.mainsite.net[/COLOR]
</VirtualHost>
<VirtualHost [COLOR="RoyalBlue"]{serverip}[/COLOR]:80>
DocumentRoot /home/newsite/public_html
ServerName newsite
ServerAlias newsite
ServerPath /home/newsite/public_html
ServerAdmin david@mainsite.net
<Directory / >
Options FollowSymLinks
AllowOverride [COLOR="Gray"]none[/COLOR]
# That will prevent mod_rewrite from working on newsite
</Directory>
</VirtualHost>
The only other comment is that your DNS may require that the “addon” domain, newsite, be under the main domain’s physical structure. Okay, if on your server, then probably not.
If on your server, though, you’ll need to do a bit more (DNS-wise) than my httpd-vhosts.conf and hosts file additions (you DID update your server’s hosts file, didn’t you?).