Redirect non www to www with .htaccess | Lessoncup Programming Blog

Thursday, 17 October 2013

Redirect non www to www with .htaccess

This lesson will show you how the domain redirect non www to www using .htaccess file. users entering your domain the address bar they won't enter www at start of the domain at that your domain want to redirect non www to www we write some code in .htaccess file. let's start the lesson.




.htaccess file

when ever you use .htaccess file you should start with RewriteEngine On.
RewriteEngine On
RewriteCond %{HTTP_HOST} domainname\.com [NC]
RewriteRule (.*) http://www.domainname.com/$1 [L,R=301]

No comments :

Post a Comment

Mohammad Khasim
Blogger | Web Developer
Hyderabad - INDIA
lessoncup@gmail.com

PHP | My SQL | JQUERY
Web Development Tools | CMS | Frameworks | SEO

Get my Latest Lessons