Menu
Successful Web Strategy Successful Web Solution
development | design | execution | marketing | conversion | success
We are here for you: 334.403.LOVE (5683) | questions@successfulwebstrategy.com

Archive for SEO

Customizing WordPress .htaccess file redirects

successful-web-blog-redirections-solutionsCustomizing WordPress .htaccess file redirects and make them stick.

August 11th 2015

Problem – Stop WordPress from rewriting our https redirects.

As part of redirecting our clients http site to https we needed to tell WordPress and well really browsers in general that when they come to an http page to instead go to the https version.
We did this and all was well until about 5 days later we notice the redirects were gone and it was back to http. So we fixed it again then randomly some days later back to http.

Well it turns out that if you change a permalink structure WordPress will rewrite the .htaccess file to reflect this (no surprise). It also turns out that WordPress will sometimes just randomly rewrite the .htaccess (surprise) for a reason that well we don’t have the answer too.

So we were getting our .htaccess file rewritten randomly and causing our https redirects to fail.

Solution – How do you prevent WordPress from rewriting .htaccess file redirects?

By default WordPress is going to have something similar to this that it will want to return to:

# BEGIN WordPress


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

# END WordPress

While we wanted to have something like this to do our https redirects:

# BEGIN WordPress


RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

The solution then is that WP will rewrite anything in between # BEGIN WordPress and # END WordPress

So we had to take out the offending code and put it into it’s on block like so:

# BEGIN WordPress —- We are maintaining the default WP write based on our permalinks sturcture


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

# END WordPress —- We close it here knowing now that WP will only rewrite to default what is between the BEGIN and END – since this is default we are safe.

# Our code taking out of the WordPress .htaccess rewrite danger area – containing the correct https redirect code.


RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

And Viola! everything works and we have not been re-written or broken in a while. Feel free to copy and paste that code and try it out – maybe take out our comments.
Thanks for reading and let us know if you have any questions or comments.

Moving a website HTTP to HTTPS with Web Master Tools

blog-http-to-https

Moving a website HTTP to HTTPS with Web Master Tools

July 23rd 2015

As many of you know Google now gives a search engine optimization (SEO) ranking benefit to SSL/Https secured sites. So I am in the process of moving all my sites to this and encouraging my clients to move their sites as well. This is even including sites that are not transferring sensitive data or are e-commerce (traditionally what TSL/SSL was used for). All new successful sites we will push to be https as well from the start.

So Google has a page that walks you through everything you need to do here:
https://support.google.com/webmasters/answer/6033049?hl=en
Go to it – follow it.

The purpose of this post is to deal with the question many will have and is not really clearly (we wrote to them asking to fix the article – so it may be updated) answered in the Google article.

Google writes:

If you haven’t already, verify you own both the old and destination sites in Search Console. Be sure to verify all variants of both the source and destination sites. For example, you should verify www.example.com and example.com, and include both the HTTPS and HTTP site variants if you use HTTPS URLs.

Our questions then:

How do I verify the variants of http and https?
Where do I go in webmaster tools to verify and transfer my site to https?
Are http and https sites seperate sites and do I need to have seperate accounts in web masters tools search console?

Answer:

Google Webmaster Tools treats https:// and http:// as separate sites. You need to add them seperately. So in other words if you already have an http site and you make the move to https then you need to go into WMT and create a new https site and verify that. Having followed the stepts in the Google article above as well and making sure to create an https specific site map.The sitemap needs to point to the https urls.

So:

  1. Follow Googles and other prep advice (https://support.google.com/webmasters/answer/6033049?hl=en)
  2. Create the https site in GMT
  3. Verify ownership
  4. Submit the updated https sitemap
  5. Test and submit the robots.txt
  6. Fetch as Google and make sure you are green.

A user (John Mueller) on stack exchange summarized it well:

If you have both http and https then you need to add both as separate sites in GWT and verify them both. Https might just be a different protocol but it’s technically possible to serve entirely different content from each. Likewise, an xml sitemap cannot contain both http and https urls, however if you have verified both in gwt then google lets you.

Which brings us to another question?

Do I need to update Google Analytics if I move a site to https/SSL?

Yes in our experience the sites we tested worked in Google Analytics automatically for a while – then as the redirects took hook that dropped off. We recommend going into GA once you have made the transfer set up the https version and view the “Real-Time” data and make sure you see yourself or someone showing up live in GA. Also monitor it closely the next days to make sure traffic doesn’t disappear or some other suspicious oddity doesn’t occur from the transfer. We have not as of yet seen a method to transfer without creating a new property. Let us know if you of one please.

Thanks for reading and let us know if you have any questions or comments.