0

I have created one wordpress site. As I write domain name without www then it opens correctaly but as I write www. in url it's not showing the site.

Please help me.. Thank you in advance.

I have edited my question and added the following part :

Following is my file : Where I have to put code provided by you ? I tried it before the "Begin Wordpress" line but still not working.

.htaccess

"# -FrontPage-"

IndexIgnore .htaccess /.?? *~ *# /HEADER */README* */_vti*

order deny,allow

deny from all

allow from all

order deny,allow

deny from all

AuthName example.com

AuthUserFile /home/example/public_html/_vti_pvt/service.pwd

AuthGroupFile /home/example/public_html/_vti_pvt/service.grp

"# BEGIN WordPress"

RewriteEngine On

RewriteBase /

RewriteRule ^index.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

"# END WordPress "

Mohan Ahire
  • 194
  • 1
  • 9

5 Answers5

1

This happens when your DNS has insufficient configuration. Your site already has an A record ("example.com" that points at some IP).

But you also need to make the www-part work by adding a CNAME record. CNAME can be configured in two basic ways:

  • *.example.com - handles all traffic such as "www.example.com" or "foo.example.com".
  • www.example.com - only handle traffic with the www.example.com sub-domain.

So you have:

A Record

Host: example.com
IP: 5.5.5.5

CNAME

Host: *.example.com (or www.example.com)

Remember also to add a MX record if you want to configure the mail domain.

Kristoffer Bohmann
  • 3,678
  • 2
  • 24
  • 34
1

Write below code in your .htaccess file

RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Pravin Vavadiya
  • 2,996
  • 1
  • 13
  • 32
0

Try to follow below steps:

1) Add CNAME record for www and set value/points to as @. OR you can do vice-versa
2) Under Wordpress, Set your domain with www under Home and Site URL. e.g. www.example.com
3) Add redirect code in .htaccess

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

In Wordpress, #3 is optional. Wordpress will manage automatically to open site with www if you set as per #2.

AddWeb Solution Pvt Ltd
  • 18,949
  • 3
  • 21
  • 50
0

You need to add a DNS A record with www

s1nb2
  • 57
  • 1
  • 5
-1

Write this in your .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
Taryn
  • 224,125
  • 52
  • 341
  • 389
  • Thank you for help but not working properly. please see the edited question and again help me. – Mohan Ahire Apr 04 '12 at 23:24
  • César: The request will never get to the .htaccess file because the www sub-domain has yet to be configured in DNS ("but as I write www. in url it's not showing the site."). – Kristoffer Bohmann Feb 10 '13 at 17:57