How do redirect www using mod_rewrite?

Pick Language to Auto Translate:
AR | BG | CA | CS | DA | DE | EL | ES | FI | FR | HI | HR | ID | IT | IW | JA | KO | LT | LV | NL | NO | PL | PT | RO | RU | SK | SR | SL | SV | TL | UK | VI | ZH | ZH-TW

With rewrite rules, it is very simple, please use this code below but do change the domain to your domain name.

Note: If you want to redirect to www then just reserve the logic

In your .htaccess


RewriteEngine on
RewriteOptions inherit

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