I have two domains - oliverhaslam.com and ojhaslam.co.uk.
Both are registered with the same company, and both have A records pointing to my server's IP address.
Both also have CNAME records pointing the www address to the equivalent non-www address (www.oliverhaslam.com to oliverhaslam.com etc.)
The issue is this: while www.oliverhaslam.com redirects to oliverhaslam.com and displays that in the browser's address bar, www.ojhaslam.co.uk directs to the correct IP, but not to ojhaslam.co.uk.
Adding the serveralias of www.ojhaslam.co.uk to my virtualhosts makes the content display in a browser correctly, but the address bar does not reflect the redirection to ojhaslam.co.uk. As I say, that is not the behaviour I see with oliverhaslam.com, and I fear that SEO etc will see www.ojhaslam.co.uk and ojhaslam.co.uk as two separate sites.
Here's my httpd.conf file:
<VirtualHost *:80>
ServerName oliverhaslam.com
ServerAlias oliverhaslam.com
DocumentRoot /var/www/
</VirtualHost>
<VirtualHost *:80>
ServerName ojhaslam.co.uk
ServerAlias ojhaslam.co.uk
DocumentRoot /var/www/photo365/
</VirtualHost>
Any ideas why having two domains, configured the same at the registrar and configured the same in httpd.conf are acting differently?
Thanks.
EDIT:
I now have this working by changing the above code to:
<VirtualHost *:80>
ServerName oliverhaslam.com
ServerAlias oliverhaslam.com
DocumentRoot /var/www/
</VirtualHost>
<VirtualHost *:80>
ServerName ojhaslam.co.uk
ServerAlias ojhaslam.co.uk
#RedirectMatch permanent /(.*) http://ojhaslam.co.uk/$1
DocumentRoot /var/www/photo365/
</VirtualHost>
<VirtualHost *:80>
ServerName www.ojhaslam.co.uk
ServerAlias www.ojhaslam.co.uk
RedirectMatch permanent /(.*) http://ojhaslam.co.uk/$1
DocumentRoot /var/www/photo365/
</VirtualHost>
The question still stands though - why was it working for one domain, but not the other?