Openshift - 将所有https网址重定向到http

时间:2015-07-25 11:17:08

标签: wordpress .htaccess http mod-rewrite https

我想禁用所有https请求,我想在openshift wordpress应用程序中将所有https请求重定向到http。

我尝试了很多代码。

此代码后没有任何事情发生。

RewriteEngine On

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

RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

我也尝试了以下代码。但它显示了重定向循环错误。

RewriteEngine on 
RewriteCond %{HTTP:X-Forwarded-Proto} https
RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [R,L]

我也尝试过创建wordpress插件。但是这段代码也向我显示了重定向循环错误。

add_action( 'template_redirect', 'hkp_ssl_template_redirect', 1 );

function hkp_ssl_template_redirect() {
    if ( is_ssl() && ! is_admin() ) {
        if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
            wp_redirect( preg_replace( '|^https://|', 'http://', $_SERVER['REQUEST_URI'] ), 301 );
            exit();
        } else {
            wp_redirect( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301 );
            exit();
        }
    }
}

我也尝试过.htaccess

中的代码

方法1。

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTPS} off
</IfModule>

方法2。

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTPS} on
    RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI}
</IfModule>

以上所有代码都没有使用openshift wordpress。能否指导我如何实现这一点。

由于

0 个答案:

没有答案
相关问题