Get FAST WordPress Support
World’s Fastest WordPress Support Since 2009  
Stop WordPress 404 Visits

Stop WordPress 404 Visits When There is Space In The URL

Are you looking to stop WordPress 404 visits?

We bet that you didn’t even know there is something happening to your website that could cause you to miss out on some important visits or even worse some conversions.

If there is a hyperlink out there in the web atmosphere that has unwanted space either at the beginning or the end, this URL if clicked on will generate a 404 visit on your website.

This means that the person that has actually clicked on the hyperlink will never reach the destination they are hoping for. Instead it is going to take them to whatever 404 error page you have set up on your website.

This is extremely common because if you are getting back links to the content on your website it is possible that those people that are creating these back blinks are not hyperlinking to the URL properly.

There are spaces in these URLs that are back links to your content and because of the spaces the visitor is never reaching the correct destination.

The good news is that there is an easy fix for this that can auto-magically remove any spaces that are part of a hyperlink coming into your website.

Before we dive into the actual process of fixing this let’s talk about how you can actually see if you do have any of these miss-formatted hyperlinks coming into your website.

Follow these simple steps below to set up a 404 monitoring plugin and see what URL is are triggering 404 visits to your website.


STEP #1 Install 404 Monitoring Plugin – Stop WordPress 404 Visits

404 Solution is a FREE plugin that provides the following features below.

Features:

  • Highly configurable – redirect specific 404 URLs to any existing page.
  • Automatically create redirects based on the URL the visitor was most likely trying to visit.
  • Get a list of 404s as they happen.
  • View logs of 404 pages and redirects including referrer data.
  • WooCommerce compatible – pages, posts, products, and custom post types are supported.
  • Display a list of page suggestions on a custom 404 page with a shortcode (any page can be a custom 404 page).
  • Basic plugin usage statistics.
  • Automatically remove redirects when the URL matches a new page or post.
  • Automatically remove manual and automatic redirects once they are no longer used.
  • Redirect based on regular expressions and include query data.

Once this plug-in is installed and set up it will begin to capture all of the URLs that are coming into your website and creating a 404 error.  

See an example of this report in the image below.

Stop WordPress 404 Visits

GET THE PLUGIN HERE – Stop WordPress 404 Visits


The URLs coming in that are generating 404 errors may look something like this below.

https://some_domain.com/about:blank

If you see this path inside of your 404 log then this is being caused by a hyperlink coming to your website that has empty space in it.

So now hopefully you have a better understanding about how to track down these 404 visits and now it’s time to explain how to easily fix them.


Stop WordPress 404 Visits – Add this to your .htaccess file

You simply need to take the below code snippet and add it to your .htaccess file.

What this snippet will do is remove any spaces that are in the hyperlink coming to your website and either the beginning, the end or in the between of the URL path.

# remove spaces from start or after /
RewriteRule ^(.*/|)[\s%20]+(.+)$ $1$2 [L]

# remove spaces from end or before /
RewriteRule ^(.+?)[\s%20]+(/.*|)$ $1$2 [L]

# replace spaces by - in between
RewriteRule ^([^\s%20]*)(?:\s|%20)+(.*)$ $1-$2 [L,R]

How to edit your .htaccess file easily…

It’s so super easy to edit your. htaccess file by using this free plugin below. No need to get access to the server or have FTP credentials. 

Stop WordPress 404 Visits 1

WP Htaccess Editor provides a simple, safe & fast way to edit, fix & test the site’s htaccess file from WP admin. Before saving, htaccess file can be tested for syntax errors. It also automatically creates a htaccess backup every time you make a change to the htaccess file.

Htaccess backups can be restored directly from the plugin, or via FTP if the errors in htaccess file prevents WP from running normally.

Stop WordPress 404 Visits 2

Hopefully this was helpful and it is a great tip to decrease the amount of 404 visit you are getting on your website and ensure that even if a back link is copied and formatted incorrectly with added space it will still reach the intended destination.

If you have any questions at all feel free to comment below.

Leave a Reply

Your email address will not be published. Required fields are marked *