How to Find and Fix Broken Links on Your Website?

In less than an hour, my client and I were both able to create 1,120 high-quality backlinks that point to 700+ pages of his website using just one line of code.

? How? To redirect almost every broken link to the correct page on his website, we used a regex expression.

This type of work is best for search engine SEO because of a few reasons.

  1. You’re making the most of what you have already done.
  2. You control the implementation, unlike other work (like Content Promotion).
  3. Your work can have side benefits such as a better user experience and a better search rank through the links.

However, the process can be difficult to understand and counterintuitive. This is especially true for the regex expressions and redirects.

These are the steps that we took to ensure all inbound links were pointed in the right direction.

Step 1. 

You are searching for broken links to your site. This is an inverse plan of broken linking that I have covered here as well as here .

You can use your Google Search Console coverage report if you don’t own a paid tool.

Navigate to Coverage Report under the Crawl section of Google Search Console.

This report shows Googlebot’s encounters with 404 codes during its crawl. This is often due to bad internal links.

You should also fix your internal links.

You’ll also find external links. Click on the crawl error to view the “Linked From” section.

You can export the top linked pages report to focus on broken external links and then drop them in a URL Status Checker.

A URL pattern is also needed to quickly redirect many links. In my client’s case, he had migrated CMS’ years ago that changed his blog’s URL pattern from – /year/month/post-name.html to /post-name/

Other than that, you can still fix URL patterns. You’ll need more time to manually redirect URLs with.htaccess or the WordPress Redirect plugin. Be careful when editing the.htaccess file.

My client was using WP Engine. He was able to test links prior to pushing the changes live. You may be able to hack a solution if you use a website builder . However, this is one area where WordPress excels over builders such as Wix and Squarespace.

You’ll be able to get better data with a paid tool such as SEMRush and LinkMiner from Mangools.

To do this, I created a giant Guide. However, you can also use other backlink tools such as SEMRush and LinkMiner.

Site Explorer will load your site and you can navigate to Broken Inbound Links.

You’re searching for a URL pattern…or prepping to do a lot more manual work.

Step 2. 

We identified the URL pattern as follows.

  • Old URL Pattern – [domain]/year/month/post-name.html
  • New URL Pattern – [domain]/postname/

We had to create a redirect to tell Googlebot (or any browser) that the –

“Hey! That post that was at /year/month/post-name.html is now permanently at /post-name/”

This instruction is known in web jargon as a Redirect.

We wanted a single URL redirect to improve user experience and web best practices. We didn’t want to redirect dates, then redirect the.html. We wanted to do it all at once.

Step 3. 

Regex stands for “regular expression” and is a shorthand for computers. Regex allows software to match patterns rather than telling it what to do with each instance.

Regex is a common issue for marketers when they use Google Analytics.

LunaMetrics’ guide to Regex in Google Analytics can be a useful resource for creating Regex.

WordPress users often have to change the date in their permalinks.

I used Yoast’s Permalink Helper to cut down on some of the Regex writing (from the same guy who made the Yoast search engine optimization plugin). This will give you a basic Regex to use.

Here’s the original code:

[code]RedirectMatch 301 ^/([0-9]4)/([0-9]2)/(? !page/)(.+)$ http://www.mydomain.com/$3[/code]

It’s all great, but I needed a single redirect for everything.

I changed the redirect to – in order to fix it.

[code]RedirectMatch 301 ^/([0-9]4)/([0-9]2)/(? !page/)(.+)\.html$ http://www.mydomain.com/$3[/code]

Do not blindly copy the code. Take a moment to fully understand what’s going on.

[code]RedirectMatch 301[/code]

This allows anyone to access your server and redirect the following pattern permanently.

[code]^/([0-9]4)/([0-9]2)/(? !page/)(.+)\.html$[/code]

URLs from the domain that contains – should be used as the source URL pattern.

  • Start with the domain
  • Ensuite, 4 numbers
  • Followed by a slash
  • Ensuite, follow with 2 numbers
  • Followed by a slash
  • Ensuite, follow the page variable form WordPress
  • Ending with.html – note the, which “escapes the period

The target URL pattern for – is

[code]http://www.mydomain.com/$3/[/code]

The target URL pattern is simply a command to visit the domain. It will be followed by the third variable in the source URL (i.e. whateverpage it is). The variable should begin and end with a space.

Step 4. 

You can add the code directly to your.htaccess file via FTP to your server to implement it.

Warning The.htaccess controls access to your website. You could cause a crash to your website if you do not understand the code correctly.

You can use the Redirection plugin or the RankMath search plugin which includes redirections.

Your code must be correct, but it’s a lot easier to use.

Split your redirect into “Source” & “Target”, and then check the Regex box.

Click Add Redirection, and you’re done!

The final and most important step is to test your redirects.

Drop a few old URLs into a crawler tool such as Screaming Frog, or a web application like HTTPstatus.io.

Also, you should load an incognito web browser and manually test several.

If your tests are successful and you see one redirect, congratulations!

You can also use this method to fix broken internal links. However, this is not always possible. However, a redirect is more effective than a URL 404.

We will be happy to hear your thoughts

Leave a reply

Sezmi
Logo
Enable registration in settings - general