mvied / wordpress-https

WordPress HTTPS is intended to be an all-in-one solution to using SSL on WordPress sites.
http://wordpress.org/extend/plugins/wordpress-https/
95 stars 41 forks source link

Feed generates HTTP Error 301 on all feeds #52

Closed G-J-Z closed 6 years ago

G-J-Z commented 8 years ago

We could not get Bloglovin to work with the feed https://www.agreencoconut.nl/feed. It turned out that while the whole blog was using https and also in the settings, content inside the feed wasn't . We found this by checking the feed validity: http://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Fwww.agreencoconut.nl%2Ffeed%2F Result: Server returned HTTP Error 301: The HTTP server returned a redirect error that would lead to an infinite loop. The last 30x error message was: Moved Permanently

When looking at the feed we immediately found that all links where not using https:

<channel>
    <title>A Green Coconut</title>
    <atom:link href="http://www.agreencoconut.nl/feed" rel="self" type="application/rss+xml" />
    <link>https://www.agreencoconut.nl</link>
    <description>Pura Vida</description>
    <lastBuildDate>Sat, 23 Jul 2016 01:22:50 +0000</lastBuildDate>
    <language>nl</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <generator>https://wordpress.org/?v=4.5.3</generator>
    <item>
        <title>Nooit meer haast</title>
        <link>http://www.agreencoconut.nl/reizen/nooit-meer-haast</link>
        <comments>http://www.agreencoconut.nl/reizen/nooit-meer-haast#respond</comments>

What can we do to fix this. It appears that some parts work but most don't. Help is appreciated.

s4ad commented 8 years ago

The following is a quick fix :

Add the code below to your theme's function.php

function s4_edit_feed_links($link) {
if(is_ssl()){
    $link = str_replace('http://', 'https://', $link);
}
return $link;
}

add_filter('the_permalink_rss', 's4_edit_feed_links');
G-J-Z commented 8 years ago

As suggestd by @s4ad I added PHP-code but it did not result in fixing the issue.

To avoid problems with upgrades or switching themes the code below was added as a plug-in and activated.

Into /wp-content/plugins/pepr-fix-permalink/pepr-fix-permalink.php:

function s4_edit_feed_links($link) {
if(is_ssl()){
$link = str_replace('http://', 'https://', $link);
}
return $link;
}

add_filter('the_permalink_rss', 's4_edit_feed_links');

PS: It is possible to add this code to ../wp-content/themes//inc/functions.php file. But this would not be upgrade proof.

headstash commented 6 years ago

I have tested this as a permanent fix and it seems to work great. Will be in the next version.