• Like Us On

 

Redirect non www to www or vice versa


Redirect non www to www or vice versa

Many times we need to redirect our website from non www to www site.This can be done mainly by two methods.One is using .htaccess and another is using cpanel.Here i will tell you both methods to redirect your site from non www to www version of your site.

1.Using .htaccess

redirect from non www to www

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
</IfModule>

redirect from www to non www

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
</IfModule>

2. Using Cpanel

1. Open Cpanel.

2.Navigate to Redirects

3. Now do as shown in image.

Share Post


comments powered by Disqus