Permanent Redirect to 301 url ( Non www to www redirect )

i am trying to redirect elgg site from example.com to www.example.com but some pages give me redirected loop error 

i used apcache 301 redirect, I added these lines in .htaccess but getting redirect loop error:

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

One more thing my website is in subdirectory.

@Steve Clay , did you have any idea ?

  • I need to see the headers involved for one redirect at least. Request headers: Host and response: Location and X-Powered-By. You can get these by opening Chrome's inspector, Network tab, select "Documents" at the bottom, and click the dark circle (Preserve Log...), then requesting the page.

    You can, of course, substitute example.org for the hostname if you want.

  • @Liang Lee

    The best way to accomplish this is via your hosting. Majority of hosting providers let you redirect from non www to www and you avoid redirect problems

    Rodolfo Hernandez

    Arvixe/Elgg Community Liaison

  • @All thanks, i have done by creating new plugin without using .htacess, i will release that on community in free time thanks