Redirect public traffic to a different subfolder, while local traffic remains unchanged

Posted by ecnepsnai on Pro Webmasters See other posts from Pro Webmasters or by ecnepsnai
Published on 2014-03-07T02:12:31Z Indexed on 2014/06/05 21:43 UTC
Read the original article Hit count: 217

Filed under:
|

I would like to have local (intranet) HTTP traffic go to the /var/www/html folder while any public traffic goes to the subfolder, /var/www/html/public

I've tried this configuration, with some variation, in httpd.conf

<VirtualHost PRIVATE-IP>
    DocumentRoot /var/www/html
    ServerName ecn
    ErrorLog /var/www/logs/error/private
    CustomLog /var/www/logs/access/private common
</VirtualHost>

<VirtualHost PUBLIC-IP>
    DocumentRoot /var/www/html/public
    ServerName PUBLIC-DOMAIN-NAME
    ErrorLog /var/www/logs/error/public
    CustomLog /var/www/logs/access/public common
</VirtualHost>

PUBLIC-IP, PRIVATE-IP, and PUBLIC-DOMAIN name are all replaced with the correct values in the actual document.

The problem is, local traffic can browse fine but remote traffic is directed to the root folder and getting 403d (because I have that folder blocked off through my .htaccess file). If I append /public to the URL it works fine.

© Pro Webmasters or respective owner

Related posts about apache

Related posts about virtualhost