Question:
Redirecting www to non-www?
?
2014-02-13 03:33:31 UTC
Hi, I'm using wordpress and I want to use domain.com instead of www.domain.com

I read the best method to avoid problems in the search engines is to go into cpanel and edit the .htaccess file to redirect. However I found 2 difference pieces of code online and since I'm not up on this, just needed some help.



FIRST SAYS THIS CODE:


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





SECOND SAYS THIS CODE:

RewriteEngine on
RewriteBase /

#Force non-www:
#RewriteCond %{HTTP_HOST} www.example.com(.*)$ [NC]
#RewriteRule ^(.*)$ http://example.com%1/$1 [R=301,L]



Really appreciate some help. Thanks.
Five answers:
2014-02-13 09:54:57 UTC
For wordpress blog or website

1. Wordpress Dashboard

2. Setting then

3. General



now click "Site Address (URL) and change your url
Mitchel
2014-02-14 09:22:18 UTC
First backup your .htaccess file.



If you use WordPress 3.8, you can change the site URL in General Setting, but you already know it :-D



It will be redirected automatically, no need to add any code in .htaccess



However if you already submitted your site in Google's webmaster tool, you need to edit "Site Settings" and "Set preferred domain" to use with www or without www.
2014-02-14 07:04:02 UTC
You need to find the .htaccess file from your website root directory. Open it and add the codes above
?
2014-02-13 11:40:11 UTC
you can change it by changing site url and wordpress url under settings on wordpress dashboard
Anty Saju
2014-02-13 20:30:30 UTC
add your code from above in your .htaccess


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...