0
votes

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 "

5
WordPress does this automatically, I would double check your DNS and see if you have a cname for www.Gareth Davies

5 Answers

1
votes

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.

1
votes

Write below code in your .htaccess file

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

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.

0
votes

You need to add a DNS A record with www

-1
votes

Write this in your .htaccess file:

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