Remove WWW from domain with .htaccess

Coding web page | Rolands Umbrovskis | March 30, 2010 6:47 pm 310 views | 1 Comment

Another good thing about removing double content is to remove or add www prefix to your domain.

Remove WWW from domain


# This will remove www from your domain
RewriteCond %{HTTP_HOST} ^www\.mediabox\.lv$ [NC]
RewriteRule ^(.*)$ http://mediabox.lv/$1 [R=301,L]

This is what I now use for all my domains – domain without www prefix.

Add WWW to domain

This probably is best for old domains like mine www.rolandinsh.lv


# This will remove www from your domain
RewriteCond %{HTTP_HOST} ^mediabox\.lv$ [NC]
RewriteRule ^(.*)$ http://www.mediabox.lv/$1 [R=301,L]

Related Posts

Removing WWW from URI (or domain) with PHP
Removing WWW from URI (or domain) with PHP

Few weeks ago I wrote how to remove WWW from domain with .htaccess. In some cases or hosting plans it's not possible to view or use .htaccess file...

Remove index.html and/or index.php from the URL
Remove index.html and/or index.php from the URL

Inspired by my discussion with Kaspars on his homepage konstruktors.com how to better remove index file. So I'll post both versions, because they...

 
 
draugiem.lv/say SekoMan.lv twitter Digg this! Add to del.icio.us! Stumble this! Add to Techorati! Share on Facebook! Seed Newsvine! Reddit! Add to Yahoo!

Rolands Umbrovskis

Web developer at "Simple Media Code" / Mediabox.lv

Follow Rolands Umbrovskis on Twitter or Facebook

1 Comment »

Atsauces

  1. April 20, 2010 Removing WWW from URI (or domain) with PHP | Full time WEB Freelancer | WordPress, BuddyPress, WordPress MU and Web developer

RSS feed for comments on this post. TrackBack URI

Leave a comment

Note: This post is over 5 months old.

 



bt bt bt bt
plugin by DynamicWP
#