0

I'm using Slim Framework on my website and I would like to avoid duplicate content by redirecting everything to "www." but I don't know what to modify in .htaccess to do that.

The original .htaccess for Slim Framework is :

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

Thank you

  • Possible duplicate of [.htaccess redirect - automatically add www. if no subdomain exists](http://stackoverflow.com/questions/12256130/htaccess-redirect-automatically-add-www-if-no-subdomain-exists) – chris85 Dec 04 '15 at 01:57

1 Answers1

0

Try:

RewriteEngine On
#non-www to www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www%{HTTP_HOST}%{REQUEST_URI} [NC,L,R]
#end of non-www to www rule
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
Amit Verma
  • 38,175
  • 19
  • 80
  • 104