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

A site that I am developing works with the format www.domain.com but when typing the domain without the www i.e domain.com I receive a error 400 bad request. How can I enable non-www for my site.

share|improve this question
    
@AurelioDeRosa no right now I made some changes and it doest work with the www also –  toocool Nov 19 '11 at 15:07

3 Answers 3

First check the DNS records for your domain. You need to have an A Record for both the www. and non-www. versions of the domain. Some providers will use an @ for the non-www. version.

Then check your server's host.conf file. This is where (in Apache at least) you tell your webserver where to direct traffic for various domains. If you have a directive for www.domain.com but not domain.com that can cause requests to fail, as your server doesn't know where to send them.

share|improve this answer

If you're using Apache, you can configure it in your control panel to always use the "www" prefix or make it to remove the "www" prefix, go to domain management and change the 'A" record to always use "www" prefix.normally this shouldn't even be a problem, because most web hosting has this already configured.

share|improve this answer

To solve your problem, if you're using Apache, you can use mod_rewrite in this way:

  • Create a text file and call it .htaccess
  • Open the file with a text editor and write:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^juve-news\.com [NC]
RewriteRule ^(.*)$ http://www.juve-news.com/$1 [R=301,NC,L]
  • Save the file and upload it in your website root folder
share|improve this answer
    
Mind the case: http_host => HTTP_HOST, nc => NC, on => On. –  Olivier Pons Nov 19 '11 at 16:03

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.