简体   繁体   English

Wordpress 从 https 重定向到 http

[英]Wordpress redirect from https to http

I am running a Wordpress SSL-Website which requires to have one tab to be non-SSL because it runs a non-secure websocket and it would be rejected due to mixed content otherwise.我正在运行一个 Wordpress SSL 网站,它需要一个选项卡为非 SSL,因为它运行一个不安全的 websocket,否则会因为混合内容而被拒绝。

In that regard I am doing a redirect in the .htaccess file:在这方面,我正在 .htaccess 文件中进行重定向:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/(stage/)$
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*) http://%{HTTP_HOST}/$1 [R=301,L]

which indeed makes this specific tab unsecure, however, it also results to the following two issues:这确实使这个特定的选项卡不安全,但是,它也会导致以下两个问题:

1.) After the switch from https to http I am loosing any wordpress status information - it basically behaves as if the user is not logged in. Going back to the other secured tabs the information is back again. 1.)从 https 切换到 http 后,我丢失了任何 wordpress 状态信息 - 它基本上表现为用户未登录的信息再次返回安全选项卡。

2.) This specific tab includes three iFrames which I may only include via https and not via http. 2.) 这个特定的选项卡包括三个 iFrame,我只能通过 https 而不是通过 http 包括。 When including them via http I am on top of issue 1.) also loosing the wordpress data base access at all.当通过 http 包含它们时,我在问题 1 之上。)也完全失去了 wordpress 数据库访问权限。

In fact the switch from https to http is only a workaround but currently a fine compromise for the meantime.事实上,从 https 切换到 http 只是一种解决方法,但目前是一个很好的折衷方案。 It works without the issues mentioned in Joomla and now I would like to know if there is way to get rid of them in Wordpress as well.它没有 Joomla 中提到的问题,现在我想知道是否有办法在 Wordpress 中摆脱它们。

Thanks in advance, best提前谢谢,最好的

Alex亚历克斯

WordPress' SECURE_AUTH_COOKIE is equal to 'wordpress_sec_'. md5(get_site_option('siteurl')) WordPress 的SECURE_AUTH_COOKIE等于'wordpress_sec_'. md5(get_site_option('siteurl')) 'wordpress_sec_'. md5(get_site_option('siteurl')) . 'wordpress_sec_'. md5(get_site_option('siteurl')) So as you change environments (secure to non-secure) that siteurl will change and your session cookie hash will be different.因此,当您更改环境(从安全到非安全)时,siteurl 将会更改,并且您的 session cookie hash 会有所不同。 You'll need the user to login on BOTH secure AND non-secure before proceeding.在继续之前,您需要用户同时登录安全和非安全。

The code in question is located at wp-includes/default-constants.php .有问题的代码位于wp-includes/default-constants.php Since this runs before any plugins/theme code.因为这在任何插件/主题代码之前运行。 You'd have to hack this at the wp-config.php level.您必须在wp-config.php级别破解它。 Then check out it's use in the wp-includes/pluggable.php file to see future modifications are needed.然后检查它在wp-includes/pluggable.php文件中的使用情况,以了解未来是否需要修改。 The pluggable file runs after plugins init, so you can hook into filters there, if needed.可插入文件在插件初始化之后运行,因此如果需要,您可以在那里挂接过滤器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM