【问题标题】:Wordpress rss feed except from https除了来自 https 的 Wordpress RSS 提要
【发布时间】:2017-06-09 04:52:44
【问题描述】:

我们的邮件列表提供商要求我强制 rss 提要不是 https,而是简单的 http。

我们的网站在 Wordpress 4.7.1 上运行,并使用 Easy HTTPS Redirection 和 SSL Insecure Content Fixer 插件来使网站正常工作。

有人告诉我,也许我应该为 .htaccess 添加一些例外,但我在论坛中找不到如何操作。

我已经创建了这个帖子,但我无法正确理解它。 htaccess force ssl except for rss feeds

这是我在 .htaccess 文件中找到的内容

# BEGIN HTTPS Redirection Plugin
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
# END HTTPS Redirection Plugin

感谢您的帮助。 格格

【问题讨论】:

    标签: wordpress .htaccess ssl rss


    【解决方案1】:

    你需要使用模板重定向钩子。

    add_action( 'template_redirect', 'template_redirect', 1 );
    
    function template_redirect() {
    
        if ( is_ssl() && ! is_admin() ) {
    
            if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'your_url' ) ) {
    
                wp_redirect( preg_replace( '|^https://|', 'http://', $_SERVER['REQUEST_URI'] ), 301 );
                exit();
    
            }
    
        }
    
    }
    

    请将您的网址粘贴到 your_url 参数中。

    【讨论】:

    【解决方案2】:

    你可以用这个:

    RewriteEngine On
    
    #Check to see if HTTPs is not on, turn it on.
    RewriteCond %{HTTP:X-Forwarded-SSL} !on
    RewriteCond %{REQUEST_URI} ^\/(foobar)
    RewriteRule (.*) https://%{HTTP_HOST}/$1 [L,R=301]
    
    #If HTTPs is on, turn it off for foobar.
    RewriteCond %{HTTP:X-Forwarded-SSL} =on
    RewriteCond %{REQUEST_URI} !^\/(foobar)
    RewriteRule (.*) http://%{HTTP_HOST}/$1 [L,R=301]
    

    将 foobar 更改为相关目录。确保在测试之前清除缓存。

    【讨论】:

    • 太棒了!我很高兴能帮上忙:)
    • 不幸的是,只有当我禁用了强制 FF 和 Chrome 等浏览器使用 https 的 WP 插件时,它并没有解决我的问题。我应该将 foobar 更改为 rss 还是 feed?
    猜你喜欢
    • 2015-12-22
    • 1970-01-01
    • 2010-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-25
    • 1970-01-01
    • 2014-02-06
    相关资源
    最近更新 更多