【发布时间】:2011-07-20 22:34:01
【问题描述】:
我的网站上有一些使用 http 的页面和使用 https 的其他页面。现在我想使用 mod_rewrite 将 www 附加到所有 URL,无论它们使用 http 还是 https。
我在 .htaccess 中有我当前的代码:
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index.php
RewriteCond $1 !^(index\.php|public|assets|robots\.txt)
RewriteRule ^(.*)$ ./index.php/$1 [L]
请只关注前两行,其余的用于其他重写规则,但我将其包括在内,以防它们对我的前两行造成任何错误。
现在这会将所有页面重定向到 http,但我希望将使用 https 的页面重定向到正确的协议。我尝试了 StackOverflow (htaccess redirect for non-www both http and https) 上的一个线程的解决方案,但它对我不起作用。
【问题讨论】:
标签: url mod-rewrite https