Even though this blog now mainly consists of drifting, motorsport, cars and other cool things, I still aim to keep my geek readers updated too! I’ve managed to source 2 different chunks of code to help any WordPress user along the way with (hopefully) improved SEO results to your blog. This post is talking entirely about that odd little file known as .htaccess, so pay attention, some real SEO advantages can come from this…
Firstly, I’ve now moved my blog from a .co.uk to a .com TLD, so I needed a htaccess mod to permanently move all requests from the old domain to the new domain. A two-liner from SEOblogr.com did it for me, and this is below
RewriteCond %{HTTP_HOST} ^(www\.)?old-domain\.co.uk
RewriteRule (.*) http://www.new-domain.com/$1 [R=301,L]
And the other part to my htaccess is the ability to remove query strings from the URL’s, and then again permanently redirect them to the blog post. A query string, by the way, is anything after the main request URI which isn’t already rewritten. ?query for example, and this code is here, taken from BrianCray.com
RewriteCond %{QUERY_STRING} !=""
RewriteCond %{QUERY_STRING} !^p=.*
RewriteCond %{REQUEST_URI} !^/wp-admin.*
RewriteRule ^(.*)$ /$1? [R=301,L]
And that’s basically it! Just put both these bits of code after the line
RewriteBase /
In your .htaccess file, and you’re good to go. I’m seeing good results already from this. /endgeek