【问题标题】:Slim Framework : redirect to www. in .htaccessSlim 框架:重定向到 www。在.htaccess
【发布时间】:2016-03-08 20:47:11
【问题描述】:
我在我的网站上使用 Slim 框架,我想通过将所有内容重定向到“www”来避免重复内容。但我不知道在 .htaccess 中修改什么来做到这一点。
Slim 框架的原始 .htaccess 是:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
谢谢
【问题讨论】:
标签:
php
.htaccess
redirect
slim
【解决方案1】:
试试:
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]