【发布时间】:2016-05-18 12:56:24
【问题描述】:
我正在尝试编辑我的 .httaccess 配置。我想将所有想法重定向到 https,但如果我尝试这个,我在 stackoverflow 上发现了什么:
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
它不会重定向。
现在我的 .htaccess 看起来像:
RewriteEngine On
# ignore all existing files and directories for rewriting
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([\d+^/]*)$ /index.php?id=$1 [QSA,L]
RewriteRule ^([\w+^/]*)$ /index.php?name=$1 [QSA,L]
重写规则如:
^([\d+^/]*)$ /index.php?id=$1 [QSA,L]
如果我愿意,工作得很好
- www.mydomain.com/523
好像
- www.mydomain.com/index.php?id=523
那么我怎样才能附加我的代码来重定向 http:// 到 https:// 并且我的旧重写规则仍然有效?
【问题讨论】:
标签: .htaccess redirect mod-rewrite https