Subscribe via RSS Feed

Forwarding Traffic To WWW Domain

You can alter the way your URL is displayed. By adding a snippet of code into your .htaccess file you can automatically rewrite the URL entered by the user. For example if a vistor goes to the address “yourdomain.com” and you have specified in your .htaccess to rewrite it with the www. then the .htaccess file will automatically change it to “www.yourdomain.com”.

The .htaccess file can be located in the root of your website and can be modifed or created in an unformatted text editor such as notepad or Dreamweaver.

Add the following snippet of code into your .htaccess file:

#Turn the RewriteEngine on.
#You will need to add these rules to the top of your .htaccess file
 
RewriteEngine on
 
#The following code will add a leading www to a domain if it is missing.
 
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

No related posts.

Tags: , , , ,

Category: .htaccess

About the Author: Hello, my name is Ben Compton and i am 18 years old. I am the site admin/creator, i decided to create this site to develop my web skills and to provide knowledge on various web development aspects; wordpress, php etc.

Comments (1)

Trackback URL | Comments RSS Feed

  1. Terrific work! This is the type of information that should be shared around the web. Shame on the search engines for not positioning this post higher!

Leave a Reply




If you want a picture to show with your comment, go get a Gravatar.