Forum Moderators: phranque

Message Too Old, No Replies

subdomain in one site being served by another subdomain

         

defanjos

9:56 pm on Jan 6, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a subdomain (images.example.com) that I want to be served by another subdomain (sub.anotherexample.com).

I created a CNAME record for example.com like:
name: images
alias to: sub.anotherexample.com.

When i go to sub.anotherexample.com, it works, but when I go to images.example.com, I get a 404

If I check the DNS of images.example.com it points to sub.anotherexample.com, so it is not a DNS issue.

I've read that I should create an server alias on anotherexample.com cpanel, but when I try to create a alias for images.example.com, it errors, saying something like: “example.com” is already owned by another user.

What am I missing?
Thanks in advance

lucy24

10:43 pm on Jan 6, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Lots of unanswered questions.

Is this happening on your own server? The reference to cpanel suggests no. Do both sites live on the same server? Do both sites use the same DNS?

to be served by another subdomain

This is a little confusing. Are you talking about URLs or about physical locations? Do you want these files to be reachable in two different ways? In fact, since you're talking about images, do you want them to be reachable at all (other than as requests by your own pages)?

saying something like: “example.com” is already owned by another user.

Where "another user" is actually you, only the cPanel doesn't know it?

I've got a nebulous feeling that what you really want is not a DNS thing but some type of proxy, but let's get some more information first. It always helps to start by explaining in English what you want to achieve. After that's been spelled out, we start hammering out the code.

defanjos

11:25 pm on Jan 6, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It is a VPS server
Both sites on same server
DNSs point to same IP (via dnsmadeeasy service)
I have access to WHM and cpanel

I'll upload images to sub.anotherexample.com, and want them to be accessed via images.example.com also.

So, if I upload "image1.png" to sub.anotherexample.com, I want to go to the following URLs: "sub.anotherexample.com/image1.png" and "images.example.com/image1.png", and be able to see the image.

Thanks

lammert

8:35 am on Jan 7, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



In order to serve data for requests of images.example.com. the server of sub.anotherexample.com must know that those requests are valid. You can do this by adding a server name alias to the virtual host definition of sub.anotherexample.com. I am not familiar with your hosting panel software so can't tell you precisely where to look for, but you have to change a file named httpd.conf, vhost.conf or similar in your httpd config directory.

The syntax will be something like:

<VirtualHost 11.22.33.44:80>

ServerName sub.anotherexample.com
ServerAlias images.example.com

#here other definitions

</VirtualHost>

Be sure to restart the Apache server for the changes to be loaded.

phranque

12:20 pm on Jan 7, 2015 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



have you tried to do a nslookup for sub.anotherexample.com and images.example.com to verify the DNS configuration is correct?

if so, please show the relevant directives from your configuration(s).
see the "related directives" list here - Name-based Virtual Host Support:
http://httpd.apache.org/docs/2.2/vhosts/name-based.html [httpd.apache.org]

defanjos

5:32 pm on Jan 7, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thank you all

I believe I have to do what lammert mentions (VirtualHost).

I looked into it, but it seems I have to use includes to modify the Virtualhost containers in WHM, unfortunately, that's a bit out of my knowledge.

lucy24

8:36 pm on Jan 7, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



it seems I have to use includes to modify the Virtualhost containers

Double-check this. In general, anything that can go in an include can equally well go in whatever is doing the including. It's just a way to keep things organized.

defanjos

8:48 pm on Jan 7, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't mean good old php includes, it is something done via WHM/cpanel.