I am having issues redirecting non-www to www via .htaccess. Non-www links are not redirecting to www when directly access non-www.host/request_params. For example I want to redirect examplehost.com/param1/param2
to www.examplehost.com/param1/param2
, but the url examplehost.com/param1/param2
redirects to www.examplehost.com/index.php
.
I am using the code below for redirecting all non-www to www links in .htaccess
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTP_HOST} ^(.+)$ [NC]
RewriteRule ^(.*)$ http://www\.%1/$1 [R=301,L]
Please give me suggestion to resolve this issue.