Wordpress SEO Expert

Improve your Google ranking with Peter Mahoney, 20+ years SEO & Wordpress experience

  • SEO Overhaul
  • SEO Campaign
  • WP Support
  • Blog
    • SEO Emails
  • Praise

Quick dirty PHP redirect

February 9, 2016 by Peter Wordpress SEO Expert

For when you need to do it and just do it quickly.

<?php header('Location:http://www.yoursite.com/new_page.html'); ?>

Filed Under: Nerd-stream, Uncategorized Tagged With: code, code snippets, PHP

Permanently moving website to a new domain

July 17, 2013 by Peter Wordpress SEO Expert

You really want to add this to your .htaccess file:

Redirect 301 / http://your-new-domain

Let’s break that down.

  • “Redirect” is pretty obvious, it tells the web server to redirect the request.
  • “301” is a special code that tells any search engines that come by that this change is permanent, and they should update their results to reflect the new URL. (Using “302” instead would set it as a temporary move.)
  • “/” just means the entire site, from the very top directory has been moved.
  • “http://your-new-domain” or indeed, whatever your new URL is, is the new domain that all requests should be sent to. Note the final “/” on the end.

Easy peasy! Now all bookmarks, and search engine results will still be valid and get people to your new address, with one short piece of code.

Filed Under: Hints & Tips, Nerd-stream Tagged With: 301, code, domain, htaccess, move address, redirect, url

http petermahoney net search engine optimisation seo code

March 4, 2013 by Peter Wordpress SEO Expert

http://petermahoney.net/search-engine-optimisation-seo-code/

Filed Under: Nerd-stream, Uncategorized Tagged With: code, seo

Displaying code snippets easily

February 21, 2013 by Peter Wordpress SEO Expert

With the new site and all I’ve some CSS to get through.

I wanted to make the “pre” element work as a code snippet display for me, and needed a fix to get it to wrap text (since the “width” attribute has been defunct for some time).

Here’s the solution!

pre {
 background-color: #F2F2F2;
 padding: 5px 5px 5px 5px;
 white-space: pre-wrap;       /* css-3 */
 white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
 white-space: -pre-wrap;      /* Opera 4-6 */
 white-space: -o-pre-wrap;    /* Opera 7 */
 word-wrap: break-word;       /* Internet Explorer 5.5+ */
}

Filed Under: Nerd-stream, Uncategorized Tagged With: code, CSS, snippets

Speeding up your site

October 30, 2012 by Peter Wordpress SEO Expert

There is a slew of methods to speed your site up–which is not only the polite thing to do for your guests–but helps with Speed Engine Optimisation (SEO) too. Google in particular looks at how quickly your site loads when deciding how to rank your site in search results.

Now, if you’re familiar with web servers then everything you need to know is written below. If not, this is the sort of thing you want to have an expert do for you; a faster site is too good an opportunity to pass up.

Browser caching is a process whereby we’re able to reduce the number of HTTP requests the server needs to process, which reduced page load times. Your server tells the visitor’s browser not to look for certain files everytime–usually the file that don’t change often anyway.

Edit your .htaccess file for your site, and include this code:

## EXPIRES CACHING ##
# by Peter Mahoney of petermahoney.com
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##

Restart your web server, and you’re done!

Noe this isn’t all there is to optimising a website for speed. Especially WordPress websites. As you’ll know by now I’m a WordPress SEO expert so I really pay a lot of attention to speed. There are plugins, image compression techniques and even extra code snippets worth using.

When it comes to plugin choice for WordPress speed I recommend WP Rocket – it does a great job out of the box and with just a few setting changes you can really push the envelope. Using that as well as a series of manual image compression techniques I’m able to improve the average WordPress site’s speed by 40%!

Speeding things up usually does require a few manual tweaks to code here and there – it’s really a job for a professional rather than just trying it yourself (it’s all too easy to stop a site working properly with this stuff.)

I can’t recommend a faster site enough. For your users, SEO – hell even the good of the web itself. Let’s get that content flying.

Filed Under: Code, Nerd-stream, Website Speed, Wordpress Tagged With: code, htaccess, search engine optimisation, seo, site speed, web server

Get FREE Wordpress SEO tips!

I send regular newsletters with WordPress SEO expert-level tips. Sign up to get them, along with my FREE e-book “Ongoing SEO Success”.

Did I mention they’re free!

Subscribe for free

Praise

I have over 2,500 5-star feedback reviews (and I’ve never received less than the full five.)

Here’s just one example, from Mike who runs Costello Entertainments:

Migration, Hosting, SEO and Speed Work on our new website all completed quickly and efficiently and Peter was most helpful in fixing an issue with a Popover on the site as well. If you’re thinking about asking Peter to do a job for you or hesitating, JUST DO IT! – He knows programming and the internet inside out, he’ll get the job done for you professionally, with a smile. I wish I could call a plumber or a tradesman to do the jobs I can’t do myself with the same level of confidence.
Read a lot more.

Recent Blogs

  • Outreach for backlinks – how to get quality links that Google will love
    I’m thinking of redirecting my Virtual Assistant work to other tasks as the generic LinkedIn work I ...
  • (Small) Pricing changes for 2025
    When COVID first hit, like a lot of people around the world I wanted to help my clients as much as possible ...
  • My site has errors – timeouts – and my host isn’t helping me
    Hi Peter, My site has been reporting errors (timeouts) which have become more regular the past week or so. I ...
  • How do we fix 404 errors after a site move or migration?
    Hi Peter, We migrated from Visualsoft to Woocommerce approx. 10 days ago and are experiencing 404 errors. ...

Legal

  • Terms and conditions
  • Privacy policy
  • Disclaimer

Prices are quoted exclusive of VAT unless expressly stated.

Also read

  • Payment information

RSS

Peter Mahoney, WordPress SEO expert blog

Recent Posts

  • Outreach for backlinks – how to get quality links that Google will love
  • (Small) Pricing changes for 2025
  • My site has errors – timeouts – and my host isn’t helping me
  • How do we fix 404 errors after a site move or migration?
  • Why does SEMRush show my ranking change so much?

© Copyright 2025 Wordpress SEO Expert · All Rights Reserved · Site by Peter Mahoney