Amazon Linux AMI Apache VirtualHost Port Redirect

I have an Amazon Linux AMI and am trying to redirect subdomain to different directories based on port number. I want default: 80 to be the production site and port: 8080 to be the dev site. Below is what I am trying to do in my httpd.conf file.

<VirtualHost *:80>
    ServerName subdomain.domain.com
    DocumentRoot /var/www/html/domain.com
    ErrorLog logs/domain.com-error_log
    CustomLog logs/domain.com-access_log common
</VirtualHost>

<VirtualHost *:8080>
    ServerName subdomain.domain.com
    DocumentRoot /var/www/html/test-domain.com
    ErrorLog logs/test-domain.com-error_log
    CustomLog logs/test-domain.com-access_log common
</VirtualHost>

      

So when I find subdomain.domain.com or subdomain.domain.com:80 it goes to the production site directory.

And when I hit subdomain.domain.com:8080 it ends up in the test site directory.

I have

Listen 80
Listen 8080

      

and

NameVirtualHost *:80
NameVirtualHost *:8080

      

included.

If I change the VirtualHost setting to IP with port to this:

<VirtualHost ###.###.###.###:8080>
    ServerName subdomain.domain.com
    DocumentRoot /var/www/html/test-domain.com
    ErrorLog logs/test-domain.com-error_log
    CustomLog logs/test-domain.com-access_log common
</VirtualHost>

      

I am redirecting me to the Linux testing page.

Am I missing something?

+3


source to share





All Articles