WordPress redirecting https to httpThursday, August 22nd, 2013

Articles, Wordpress

We recently transferred a static website using SSL (e.g. https://www.mywebsite.com) to wordpress. It was decided that we would no longer be serving the pages via https, but did not want to lose any traffic or ranking in google.

WordPress thankfully allows users to setup permalinks (permanent urls to pages / posts etc)  so the urls on the site can be search engine friendly. We typically use /%postname%/ structure which generates the following in an .htaccess file

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

This is great as all the pages now have nice looking links but doesn’t solve the issue where old URLs need to point to the new ones. i.e. https://www.mywebsite.com/example_page.php to http://www.mywebsite.com/example-page/

For this we applied a plugin called 301 redirect which simply gives you a UI to redirect your pages without having having to add the URLs to your .htaccess file which can be a pain to manage and a slight typo could potentially disable access to the site altogether! (There are many other similar 301 redirect plugins out there, use whatever works for you)

Although this plugin does what it says on the tin, it wasn’t very helpful in redirecting https traffic to http, infact the redirects wouldn’t even show the wordpress 404 error.

The fix that needed to be applied was within the .htaccess file, and was quite simple:

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]

2 lines were added just below the RewriteEngine On statement, this checks for https (SSL) traffic before the redirect rules even kick in.

Problem solved! Site traffic was being redirected and all the new pages are successfully replaced in googles index without any issues.

Things to keep in mind:

  1. An SSL certificate is still required
  2. Browsing to the permalinks page after applying this fix will replace the .htaccess file with the original redirect code deleting the changes.
  3. Applying plugins that use the .htaccess file could alter the newly added code as well

Obviously keep an eye on your webmaster tools and pick up any 404 errors from within the sitemap.

Happy migrating!

Like it? Share it!

Tagged with:

Feedback (11)

Leave a Comment
  1. ahmad says:

    Thanks so much! 🙂

  2. Mohd Asad Pasha says:

    Need help on how to redirect all the https old links(whenever user opens the website using https) to the http in wordpress multi site

  3. V says:

    You say that “An SSL certificate is still required”?

  4. Phillip Reynolds says:

    I’m using this but browsers are still getting stuck. I get an error about too many redirects.

  5. abhi says:

    Thanks! your solution worked.

  6. Bobby says:


    this is what im looking for, thankyou for the sharring and know my vps is running good

  7. John P says:

    Thank you for sharing this code. This actually made the trick. Good thing I came across this easy to follow codes about redirection.

  8. Mastro says:

    Wow! it did the trick!

    Thanks so much!

  9. Mastro says:


    I had a similar situation: I went back from a full-htts site to a http with https back-end. I’d like to ask you how can I edit this code so that I can still use https in wp-login/wp-admin?

    At the moment, with that code I’m always redirected in http, even when trying to login the back end.

    Sorry for bothering you but I’m not very .htaccess-friendly.


Leave a Comment

You can use these HTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>