How to redirect a website
- Details
- Category: Tutorials
- Created on Sunday, 22 April 2012 12:03
- Written by Paul Prisacaru
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.
