I just find it hard and not sure how to use mod_rewrite for my domains and sub-domains.
all I want to do is to redirect the following:
1- from either www or non www domain to another domain
www.domain.net || domain.net --> mydomain.com
2- *force www sub-domain to non www sub-domain *
www.sub.domain.com --> sub.domain.com
I tried the following code for the 1st part and it worked, but got me in trouble causing some conflict with sub-domains.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain\.net$ [OR]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]
I believe there is a fix, but not sure how!!
I went through many articles, but didn't find the right solution.
any idea how to do that??
Thanks,