How to redirect a website

To redirect non-www and www versions of the site to the same address, you must add a code in the file .htacces.

If you try to type in the browser wdevp.com you'll see that page is loaded www.wdevp.com because has been made this redirect in .htaccess.

Redirect domain.com to www.domain.com

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

 

Redirect www.domain.com to domain.com

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

ATTENTION: Replace domain with name domain and .com with your site extension.

Add comment


Security code
Refresh

Donate

Please consider supporting our efforts.

Amount: 

Advertisment

Links