3

I'm dealing with a very strange problem when trying to configure a new sub-domain on a Virtual Machine.

The problem is simple to explain:

I have two virtual Hosts entries on my httpd-vhosts.conf pointing to the same path. Both should should have the same behavior as they are equally configured as you can see below:


#
# FIRST ENTRY #######################
#
<VirtualHost www.jorgevalhondo.com:80>
    ServerAdmin you@localhost.com
    DocumentRoot /opt/lampp/htdocs/trabsi
    ServerName www.development.trabsi.com
    ServerAlias www.development.trabsi.com
    ErrorLog logs/jorgevalhondo-error_log
    CustomLog logs/jorgevalhondo-access_log common
</VirtualHost>


#
#SECOND ENTRY ####################
#
<VirtualHost www.development.trabsi.com:80 development.trabsi.com:80>
    ServerAdmin info@trabsi.com
    DocumentRoot /opt/lampp/htdocs/trabsi
    ServerName www.jorgevalhondo.com
    ErrorLog logs/trabsi-error_log
    CustomLog logs/trabsi-access_log common
</VirtualHost>

Everything works nice with the First Entry:


With the second one:

but

You don't have permission to access / on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Any Ideas about what could be wrong here, and how to solve it? Feel free to follow the mentioned links to check the problem live.

Thanks.

Buendiadas
  • 851
  • 1
  • 11
  • 26

3 Answers3

1

It's a DNS issue, check the details:

nmap -p 80 www.development.trabsi.com

Returns:

Starting Nmap 6.40 ( http://nmap.org ) at 2015-06-01 04:58 JST
Nmap scan report for www.development.trabsi.com (217.160.186.97)
Host is up (0.28s latency).
rDNS record for 217.160.186.97: clienteservidor.es
PORT   STATE SERVICE
80/tcp open  http

Nmap done: 1 IP address (1 host up) scanned in 0.85 seconds

Then, the same command for development.trabsi.com should point to the same IP, but it's not:

nmap -p 80 development.trabsi.com

Starting Nmap 6.40 ( http://nmap.org ) at 2015-06-01 04:59 JST
Nmap scan report for development.trabsi.com (217.160.132.248)
Host is up (0.27s latency).
PORT   STATE SERVICE
80/tcp open  http

Nmap done: 1 IP address (1 host up) scanned in 0.85 seconds

Finally, if you run the same command for www.jorgevalhondo.com and jorgevalhondo.com you would see that they point to 217.160.132.248 IP, which is the same you get for development.trabsi.com, but not the same for www.development.trabsi.com (217.160.186.97)

Therefore, it's just a DNS issue, please contact you DNS provider.

Kraviz
  • 511
  • 4
  • 5
  • It seems that here is a solution: http://stackoverflow.com/questions/10642426/htaccess-rewrite-subdomain-to-directory – Kraviz May 31 '15 at 04:48
0

These VHosts have different IPs but the same ServerName. In this case the matching VHost should be the first one, but you are addressing it by another IP. This cause a mismatch an error. You should rename the first VHost.

umka
  • 1,655
  • 1
  • 12
  • 18
  • (Edit) Sorry I forgot to change it, I changed after the problem came testing. I make a new Edit. Thanks anyway – Buendiadas May 30 '15 at 18:53
0

not a DNS issue, but vHost configuration:

example for first:

<VirtualHost *:80>

   ServerName jorgevalhondo.com
   ServerAlias www.jorgevalhondo.com
   # ServerAlias *.jorgevalhondo.com

   # custom config ...

</VirtualHost>

example for second:

<VirtualHost *:80>

   ServerName development.trabsi.com
   ServerAlias www.development.trabsi.com
   # ServerAlias *.development.trabsi.com

   # custom config ...

</VirtualHost>

ServerAlias also supports wildcards - in case you want to match any.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216