Moving WordPress to https and keeping your feeds alive for Feedburner (avoiding 400 error)

We recently moved the ALT Online Newsletter, which is a self-hosted WordPress site, to https/SSL. We did this before Google announced it would use https as a rank factor in it’s search results so hopefully it will also have a positive boost to our traffic. To do this we opened the WordPress dashboard and switched the WordPress and site URLs to https: 

address and site url

This setting handles the urls generated by WordPress for menus and post links but doesn’t effect hardcoded links in posts or inbound links. To handle these we added a couple of lines to our .htaccess file:

# HTTPS redirect
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>

This detects any urls with http and redirects to the https equivalent. All seemed to be fine until Matt Lingard noticed that our Feedburner RSS feed wasn’t distributing posts anymore. The issue … Feedburner can’t handle feeds served from https generating a ‘Received HTTP error code 400 while fetching source feed’:

Received HTTP error code 400 while fetching source feed.

The solution is to detect FeedBurner and not give it https like so:

# HTTPS redirect
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_USER_AGENT} !FeedBurner    [NC]
RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>

All straight forward enough but there is one last kicker. Feedburner caches your feed so when you go to Feedburner and Edit Feed Details and click ‘Save Feed Details’ it may still show as a 400 error. You can either wait for the cached version to clear to see if your changes have worked (or as I did spend an hour trying to work out why it wasn’t fixed) or trick Feedburner to ignore it’s cached version with some trash at the end of your url as a querystring e.g. http://newsletter.alt.ac.uk/feed/?source=feedburner

chevron_left
chevron_right
css.php