Go Settings โ General: WordPress Address (URL) Website Address (URL)
And install both of them on www.yoursite.com (instead of yoursite.com), wordpress automatically configures all the URLs on www.yoursite.com and what it is.
If this is not enough, you should by no means edit the .htaccess file, since at any time when you save or reload your permalink settings, Wordpress will overwrite your .htaccesss (some plugins can do this).
If you want to rewrite your URL, you must do it using WP Rewrite (Codex) , or if you want a slightly simpler approach, there is a good plugin for Redirection (Catalog of plugins Wordpress.org) .
In the Redirection plugin, you can simply set the parameters to * .mydomain.com / * to redirect to www.mydomain.com/* with 301, and this will take care of your htaccess if you keep the plugin active.
Hope this helps :)
Norris
source share