Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Why can I visit my own site: http://www.example.com but not http://example.com, which gives me

HTTP Error 403 (Forbidden): The server refused to fulfill the request

How do it fix it?

I wrote the site and upload to remote server.

share|improve this question

migrated from superuser.com Aug 31 '12 at 5:33

This question came from our site for computer enthusiasts and power users.

    
Is it your own site or some other site? E.g. are you asking how can you fix this on your web server, or just want to know why it happens while you're browsing the web? –  haimg Aug 31 '12 at 5:15
1  
You have to configure the server for both but 'how' really depends on depends on your set. You really have to give more information. –  Matteo Aug 31 '12 at 5:15
1  
If you're able to edit your DNS records, the simplest fix is to set the naked domain A-record (not www) to the IP on here: wwwizer.com which will automagically redirect visitors without the www, to the www. Alternatively you need to make rewrite rules, but I don't think you're using Apache, so more details are helpful. –  ionFish Aug 31 '12 at 5:35
    
I don't have my own server but uploading to a 3rd party hosting service. –  KMC Aug 31 '12 at 5:39
    
Please use the RFC2606-mandated example.com domain in questions. –  kinokijuf Aug 31 '12 at 7:39

3 Answers 3

mickburkejnr is close, but not entirely right. The problem is not with DNS (it could be, but that's unlikely). The problem is that your web server isn't configured to respond to queries for your site without the "www" prefix with the appropriate site.

Keep in mind that "www" is just a normal subdomain. "google.com" is the root site, "www.google.com" is a subdomain, just like "mail.google.com" is. If you wanted "mail.google.com" and "google.com" to go to the same place, then you'd have tell your webserver that.

Generally, the best solution is to redirect from "www" to the non-www version of the site (some prefer the other way; as you can see, SE sites don't). You can find examples of how to do that with common webservers easily using Google.

With Apache, I like to simply use the redirect directive in a separate virtual host:

<VirtualHost *:80>
    Server www.domain.com
    Redirect permanent / domain.com
</VirtualHost>
share|improve this answer
    
+1 And I added a non-redirecting alternative configuration. –  msanford Aug 31 '12 at 13:55

You DNS record isn't set up to accept traffic to the server without the www. This is a simple A record, and all it will contain is either a blank space or "my0wnsite.com".

If you can't change the DNS records yourself, contact either your registrar or your hosting company and they will sort this out fairly quickly for you.

share|improve this answer

Tom's diagnosis is correct. I will offer another server configuration which serves a slightly different function than Tom's:

<VirtualHost *:80>
    ServerName domain.com
    DocumentRoot /var/www/domain
    ServerAlias www.domain.com
</VirtualHost>

Tom's configuration will cause the server to redirect www.example.com to example.com and then serve content, whereas the above configuration will serve the same content without redirecting.

share|improve this answer
    
Why the downvote? –  msanford Sep 4 '12 at 15:58

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.