Vote Up 0 Vote Down

Redirect a domain from www to non www

I wonder how to redirect from the website name to I have tried the following with no success. Where I am going wrong ?

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


Vote Up 0 Vote Down
Redirecting www to non-www and vice versa are good for search engine optimization. Because search engines policy is to treat and as of different domains.

I prefer to redirecting www to non-www because its so pleasing to look.

Follow these steps for redirecting www to non-www

Step 1:

Open the **.htaccess**  file in the document root i.e. in /public_html folder. If not exists
create one.

Step 2:

Find the following lines in that htaccess file or add it if not found at the top of the file.

RewriteEngine on
RewriteBase /

Step 3:

Add the following lines after the above lines (Found in step 2). The only difference is that I removed forward slash in your code.

#redirect www to non www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

Step 4:

After uploading your file to server find type 
It will redirect you to
flag | link |

Your Answer

Login before answering

Login with facebook