Can you control a CNAME?

Using a single web hosting account to host multiple sites

Can you control a CNAME?

Postby pvfish » Wed Oct 21, 2009 9:12 am

OK, I looked all over the forum for something similar to this and I could not find. I am sure it is out there, but I can't find it - so here goes.

I have a e-commerce store that is located and the address is:

store.domain.com

Now our main hosting for our site domain.com is with NetSol, and currently there is a redirect setup to send anyone who goes to domain.com or www.domain.com it redirects them to store.domain.com. Works great, no problems with that. We plan to use domain.com in the future and have the store.domain.com branch off of it but it will still be on a totally different server.

The way we are required to setup our store.domain.com is through the use of a CNAME. So I setup a CNAME Record that goes something like:

Alias "store" refers to other host "11233.56789.servertrust.com."

If I understand CNAME correctly essentially store.domain.com is an alias for 11233.56789.servertrust.com.

So here is my issue....

When a user directly types store.domain.com into their browser it works perfect, when they type domain.com it works perfect, when they type www.domain.com it works perfect, but when they type www.store.domain.com it returns an error saying it can't find the server.

I thought I would try to do another CNAME and make www.store an alias also. But this is an problem because it returns a url that causes issues.

I guess what I am asking is if there is a way to, and if it would be correct to, redirect www.store.domain.com to store.domain.com (without the www)

I do have this in my .htaccess file:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?store\.domain\.com$ [NC]
RewriteRule .* http://store.domain.com/ [R=301,L]

But it does not seem to do anything.

Any help is greatly appreciated and if any clarification is required please let me know.

Thanks in advance

P
pvfish
 
Posts: 13
Joined: Sat Jan 05, 2008 5:29 pm

Postby richardk » Wed Oct 21, 2009 10:20 am

I thought I would try to do another CNAME and make www.store an alias also. But this is an problem because it returns a url that causes issues.

What happens exactly? The server (11233.56789.servertrust.com) probably doesn't understand what to do when the request reaches it. Can't you set up a redirect similar to the www.example.com and example.com redirects?

I guess what I am asking is if there is a way to, and if it would be correct to, redirect www.store.domain.com to store.domain.com (without the www)

I do have this in my .htaccess file:
Code: Select all
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?store\.domain\.com$ [NC]
RewriteRule .* http://store.domain.com/ [R=301,L]

But it does not seem to do anything.

Mod_rewrite is processed when the request reaches the server. Without correct DNS (eg. a CNAME) to get the request to the server mod_rewrite can't be processed. (And even then the server needs to know what to do with the request.)
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby pvfish » Wed Oct 21, 2009 4:40 pm

What happens exactly?

When I create a CNAME at Net Sol that www.store or www.store.example.com is an alias for store.example.com the URL shows the following when www.store.example.com is typed in the address bar.

http://store.example.com/Default.asp?Redirected=Y

It does resolve correctly, but that is kind of a screwed up url for a customer to see.

Can't you set up a redirect similar to the www.example.com and example.com redirects?


By that can I assume you mean setup the redirect on the server where store.example.com points? If so, it is a "box solution" e-commerce hosting place, and they allow limited 301 redirect access and only through their stupid form. Very annoying that you can't control things exactly how you want to.

I was hoping that I could control this from my primary domain hosting platform at Net Sol somehow. Or since "store" is actually controlled by my e-com platform, woul dit have to happen there?

Just a question, how is it that I can type www.finance.yahoo.com in the address bar and it redirects to just finance.yahoo.com? I realize I am not Yahoo, and I am probably be comparing apples and oranges.

Thanks -

PV
pvfish
 
Posts: 13
Joined: Sat Jan 05, 2008 5:29 pm

Postby richardk » Thu Oct 22, 2009 10:18 am

By that can I assume you mean setup the redirect on the server where store.example.com points?

No, i meant a redirect like the www.example.com to store.example.com redirect, where ever that is. From what you said, it sounded like it was controlled by the NetSol control panel. How exactly is it set up? Does it use mod_rewrite? Where is the mod_rewrite for it?

If so, it is a "box solution" e-commerce hosting place, and they allow limited 301 redirect access and only through their stupid form. Very annoying that you can't control things exactly how you want to.

So you can't put mod_rewrite on the store.example.com/11233.56789.servertrust.com server?

Just a question, how is it that I can type www.finance.yahoo.com in the address bar and it redirects to just finance.yahoo.com? I realize I am not Yahoo, and I am probably be comparing apples and oranges.

They have total control and lots of experienced people. This shouldn't be that hard to do, you just need to get the request (to store.example.com) to a server that the redirect can be done on.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby pvfish » Thu Oct 22, 2009 10:40 am

How exactly is it set up? Does it use mod_rewrite? Where is the mod_rewrite for it?


Sorry for the confusion. Our domain example.com, has a hosting with NetSol, so the example.com to store.example.com is in an htaccess file in the main directory for example.com.

Code: Select all
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www.store.example.com) [NC]
RewriteRule ^(.*)$ http://store.example.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^(www\.)?example\.com$ [NC]
RewriteRule .* - [L]
RewriteRule ^(index\.html)?$ http://store.example.com/ [R=301,L]
RewriteRule ^aboutus\.html$ http://store.example.com/about_us_a/1.htm [R=301,L]
RewriteRule ^privacy\.html$ http://store.example.com/Terms_privacy.asp [R=301,L]


So you can't put mod_rewrite on the store.example.com/11233.56789.servertrust.com server?


They have some form based 301 redirect page, it is not true mod_rewrite, or at least it is not total control. I don't have access to the root directory on that server, very limited and a pain.

I don't completely understand CNAME records, even after much reading. But since I am using CNAME to route the store.example.com traffic to the 11233.56789.servertrust.com, would that be where the redirect needs to happen?

Thanks

PV
pvfish
 
Posts: 13
Joined: Sat Jan 05, 2008 5:29 pm

Postby richardk » Thu Oct 22, 2009 11:45 am

But since I am using CNAME to route the store.example.com traffic to the 11233.56789.servertrust.com, would that be where the redirect needs to happen?

Yes, but you can try setting the www.store.example.com sub domain to a CNAME of example.com and doing the redirect there (because you have more control). You may need to set up a sub domain in your NetSol control panel.

I don't completely understand CNAME records, even after much reading.

  • The user requests www.store.example.com
  • A DNS request is made for www.store.example.com
    • The DNS request for www.store.example.com returns a CNAME to other.example.com
    • The DNS request for other.example.com returns an A record to an IP address 1.2.3.4
  • A HTTP request is made to 1.2.3.4. The HTTP Host header will be set to www.store.example.com.
  • Apache (or whatever HTTP server) will receive the request.
  • Apache will look for configuration for this domain (www.store.example.com). If it's not found it will probably return an error/default page.
  • If it is found then configuration will be processed. Near the end will be .htaccess file mod_rewrite redirects.


Edit: Added "The DNS request for ".
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby pvfish » Thu Oct 22, 2009 2:52 pm

I think I have got where you are going with the CNAME and setting up a sub domain. That makes sense, as then I would actually be able to control it. As opposed to not being able to control it like it is now.

I will make some changes and post my results.

Thanks for your help.

PV
pvfish
 
Posts: 13
Joined: Sat Jan 05, 2008 5:29 pm


Return to Domain Handling

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

cron