【问题标题】:Redirect from wordpress htaccess to http to https从 wordpress htaccess 重定向到 http 到 https
【发布时间】:2019-04-11 13:36:08
【问题描述】:

这是我的 wordpress htaccess 文件代码。在激活 ssl 证书之后,现在我想将 http 重定向到 https。但它不起作用。什么是 .well-known/acheme-challenge?这个文件夹存在于我的根文件夹中。任何人都可以帮帮我

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !
^/\.well-known/pki-validation/[A-F0-9]  {32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !
^/\.well-known/pki-validation/[A-F0-9]  {32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule . /index.php [L]`enter code here`

#结束WordPress

【问题讨论】:

标签: wordpress .htaccess http ssl https


【解决方案1】:

试试这个

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

请参考https://serverguy.com/servers/redirect-http-to-https/

【讨论】:

  • 使用header()重定向怎么样?喜欢($_SERVER['REQUEST_SCHEME'] != 'https') ? header('location:https://www.example.com') : null;
  • 谢谢。我更改了 htaccess 文件。但也会尝试您的解决方案
猜你喜欢
  • 2017-07-18
  • 1970-01-01
  • 1970-01-01
  • 2018-11-12
  • 1970-01-01
  • 1970-01-01
  • 2014-03-30
  • 2016-09-01
相关资源
最近更新 更多