【问题标题】:All links are not redirecting to https from http所有链接都没有从 http 重定向到 https
【发布时间】:2015-04-10 18:52:04
【问题描述】:

我已尝试关注;

如果用户尝试访问我的网站http://test.com,它将重定向到https://test.com,但如果用户尝试访问像http://test.com/test1 这样的内部页面,它不会重定向到https。我在 .htaccess 文件中尝试了以下代码。

RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

完整的 .htaccess 文件

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

</IfModule>

【问题讨论】:

标签: php wordpress .htaccess mod-rewrite redirect


【解决方案1】:

而不是测试!on 测试off -

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

【讨论】:

  • .htaccess 文件的其余部分是什么样的?
  • &lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] RewriteCond %{SERVER_PORT} ^80$ RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R] &lt;/IfModule&gt;
  • 请不要在 cmets 中转储代码。使用附加信息更新您的原始帖子。
猜你喜欢
  • 2015-10-14
  • 1970-01-01
  • 1970-01-01
  • 2014-05-28
  • 1970-01-01
  • 2015-12-27
  • 2019-06-18
  • 1970-01-01
  • 2018-01-21
相关资源
最近更新 更多