Twitist Forums
Redirecting www to non-www? - Printable Version

+- Twitist Forums (http://twitist.com)
+-- Forum: General Social Media & Marketing Forums (/forum-8.html)
+--- Forum: SEO Search Engine Optimization (/forum-30.html)
+--- Thread: Redirecting www to non-www? (/thread-143796.html)



Redirecting www to non-www? - David - 04-27-2014 10:39 PM

Hi, I'm using wordpress and I want to use domain.com instead of http://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:

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




SECOND SAYS THIS CODE:

RewriteEngine on
RewriteBase /

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



Really appreciate some help. Thanks.
I know about the wordpress dashboard settings, but that's not enough is it?


- Santosh - 04-27-2014 10:43 PM

you can change it by changing site url and wordpress url under settings on wordpress dashboard


- Aassif - 04-27-2014 10:44 PM

For wordpress blog or website
1. Wordpress Dashboard
2. Setting then
3. General

now click "Site Address (URL) and change your url


- Anty Saju - 04-27-2014 10:46 PM

add your code from above in your .htaccess


- Kenny - 04-27-2014 10:52 PM

You need to find the .htaccess file from your website root directory. Open it and add the codes above


- Mitchel - 04-27-2014 11:01 PM

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.