【发布时间】:2015-02-12 22:15:04
【问题描述】:
我很感激这些问题已经被完成了,但我似乎无法找到我需要的确切答案,所有最接近我的人都将非 www 重定向到 www,但我需要它反过来。
所以,我想做的是始终强制 www 为非 www,从 url 中重写 index.php,并始终强制站点为 SSL。
除了强制 SSL,我有以下所有功能,我尝试了很多不同的方法,但总是出现无限循环:
# Rewrite www to non www
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>
Rewrite the index.php out
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
RewriteRule (.+) index.php?p=$1 [QSA,L]
</IfModule>
【问题讨论】:
标签: .htaccess mod-rewrite ssl