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
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]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.