.htaccess http 到 https 和 mvc 查询字符串
.htaccess http to https AND mvc query string
所以,问题是,在我的 VirtualHosts 中,我已经重定向到 https,如下所示:
...
Redirect permanent / https://www.example.com/
...
然后在 .htaccess 中我
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/ [QSA,L]
但是当键入 http://example.com, in url appears https://www.example.com/?_url=/
为什么不应该出现“?_url=/”。
阿帕奇版本:2.4.7
从 Apache 配置中注释掉这一行:
Redirect permanent / https://www.example.com/
然后在 root .htaccess 中使用此代码:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?_url=/ [QSA,L]
所以,问题是,在我的 VirtualHosts 中,我已经重定向到 https,如下所示:
...
Redirect permanent / https://www.example.com/
...
然后在 .htaccess 中我
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/ [QSA,L]
但是当键入 http://example.com, in url appears https://www.example.com/?_url=/
为什么不应该出现“?_url=/”。 阿帕奇版本:2.4.7
从 Apache 配置中注释掉这一行:
Redirect permanent / https://www.example.com/
然后在 root .htaccess 中使用此代码:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?_url=/ [QSA,L]