Subdomain does not work with www
I am dealing with a very strange problem while trying to set up a new subdomain in a virtual machine.
The problem is simple:
I have two virtual host entries in my httpd-vhosts.conf pointing to the same path. Both should have the same behavior as in the same configuration as shown 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 well with the first entry:
- jorgevalhondo.com Returns 200 ok
- www.jorgevalhondo.com Returns 200 ok
With the second:
- development.trabsi.com β Returns 200 ok
but
- www.development.trabsi.com β Returns the following error:
You do not have permission to access this server / on this server. In addition, a 404 Not Found error was encountered while trying to use the ErrorDocument to process the request.
Any ideas on what might be wrong here and how to solve it? Feel free to follow the links provided to check the issue live.
Thank.
source to share
This is a DNS problem, check the details:
nmap -p 80 www.development.trabsi.com
Return:
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 doesn't:
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 will see that they point to the 217.160.132.248 IP you get for development.trabsi.com , but not the same for www.development. trabsi.com ( 217.160.186.97 )
Hence, this is just a DNS issue, check with your DNS provider.
source to share
not a DNS issue, but the vHost config:
example for the first:
<VirtualHost *:80>
ServerName jorgevalhondo.com
ServerAlias www.jorgevalhondo.com
# ServerAlias *.jorgevalhondo.com
# custom config ...
</VirtualHost>
example for the 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.
source to share