Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to forward my root domain(yourdomain.com) to www.yourdomain.com Should I delete the A record of the root domain and then setup 301 permanent forwarding to www.yourdomain.com?

I am hosting my app on heroku. So I don't really have an IP address to setup an A record.

The thing is I first deleted the A record of my root domain and then forwarded it. I pinged it and here is the result -

ping yourdomain.com
ping: cannot resolve yourdomain.com: Unknown host

Update and some more information - I am hosting a static website. And managing the DNS on cloudflare.com I added an A record for yourdomain.com -> 184.168.221.51 Just an random IP.

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

Ask you DNS provider whether they can set up a 301 HTTP redirect from yourdomain.com to www.yourdomain.com. Several DNS providers do this for free in their own webserver.

CloudFlare can solve HTTP redirect too: https://support.cloudflare.com/hc/en-us/articles/200172286-How-do-I-do-url-forwarding-with-CloudFlare-

Or you can use wildcard domains names:

* CNAME yourapp.heroku.com

Heroku has a quite good description about the different solutions: https://devcenter.heroku.com/articles/custom-domains

share|improve this answer
add comment

if you remove A record, then you won't be able to setup your 301 redirect, you should put it back and do 301 within your web server.

* UPDATE *

by pointing A record to "random IP" won't really solve anything, UNLESS you manage a web server on that random IP and can set 301 redirect there (which I'm sure you have no control over it) so solution is simple here, point A record to RIGHT IP address and then setup your 301 redirect.

share|improve this answer
    
I am hosting my app on heroku. So I don't really have an IP address to setup an A record. –  user182332 Oct 17 '13 at 16:34
    
@user182332 First, that's important information, and really something you should have told us in your question. You should edit it your question to include that information.. Second, without some DNS entry for yourdomain.com you can't do anything on the web server level (like a 301 redirect). If you can't create an A record for that domain, you can't do what you want. –  voretaq7 Oct 17 '13 at 16:45
    
I just edited the question! Some more information: I am hosting a static website. And managing the DNS on cloudflare.com I added an A record for yourdomain.com -> 184.168.221.51 Just an random IP. –  user182332 Oct 17 '13 at 16:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.