Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

If I have 2 domains, altoonadesign.com and programming-perils.com that are both pointed to the same server.

How can I make programming-perils site root the blog folder on the real site root. and disallow access to the blog folder from altoonadesign.com using .htaccess?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I'm going to make a leap and assume you're using Apache. You'll want to set up separate VirtualHost blocks for each site (or different site files each containing a virtualhost block, however you're comfortable), and set them to have different DocumentRoots.

<VirtualHost *:80>
    DocumentRoot /var/www
    ServerName altoonadesign.com
    ServerAlias www.altoonadesign.com
    ...
    <Directory /var/www>
        Order allow,deny
        Allow from all
    </Directory>
    <Directory /var/www/blog>
        Order allow,deny
        Deny from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot /var/www/blog
    ServerName programming-perils.com
    ServerAlias www.programming-perils.com
    ...
    <Directory /var/www/blog>
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

A better option (so you don't need the /blog in place) may be to move the blog files outside of the tree that contains the other site.

share|improve this answer
    
+1 Thanks, also is there a way to do this using just .htaccess? –  JD Isaacks Mar 4 '11 at 14:11
    
@John Yes, but it would have to be a rather terrifying mess of RewriteRules (with RewriteConds determining the domain). It would not be pleasant ;) –  Shane Madden Mar 4 '11 at 15:14

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.