• Skip to primary navigation
  • Skip to main content

Managed WordPress Security for Pennies a Day. Call (619) 479-6637

Managed WordPress Security with Heart

MENUMENU
  • Why HackGuard.com? Why Choose HackGuard.com?
  • HackGuard.com WordPress Managed Services Rates WordPress Managed Services Rates
  • HackGuard.com Articles HackGuard Articles Library
    • Hack Guard Customer Testimonials
    • Top 20 WordPress Plugins to Avoid
    • Why Should I Maintain My Own WordPress Website’s Backups?
    • How to Improve Junk Email Filtering at Gmail
    • WordPress 6.0.3 Security Release – Updated?
    • About that “Weekly jQuery Migrate Status Update” email
    • How to Change a WordPress User from Subscriber to Administrator Role
    • WordPress 4.9.3 – Going into the tunnel and never coming out…
    • How Do I Migrate WordPress to a Different Domain Name?
    • Community Blogging: A Short Guide
    • WordPress Troubleshooting and How to Fix WordPress Errors
    • Is My Web Host Secure? Maybe not…
    • How to remove the subdirectory name from your WordPress website address
    • How can I improve the performance of my WordPress website?
    • How can I improve the performance of my WordPress blog (Part 2)
    • Protecting WordPress Against Brute Force Attacks
    • How do I reset my WordPress password?
    • How To Clear Cron Jobs in WordPress
    • xmlrpc.php and Pingbacks and Denial of Service Attacks, Oh My!
    • Free Website Monitoring Services, well, mostly free...
    • How to choose a secure web hosting company for a WordPress website
    • WordPress 404 Page Setup - Do You Have Five Minutes?
    • Can mod_pagespeed Improve Page Load Speed (external link)?
    • Yoast WordPress SEO Settings and Recommendations
    • Is Your Mom Missing Her BUMM?

WordPress 404 Page Setup – Do You Have A Few Minutes?

Do you have have five minutes?Most WordPress themes include a 404.php file.

If your does not it’s likely that adding a custom 404.php file will simply work out-of-the-box.

Below is my recommended coding for your 404.php file.

First, duplicate your index.php file, then rename as: 404.php

Note where the body text section is located within the file and simply replace with this example below. Change the descriptive text and styling as needed:

<div id="content" class="narrowcolumn">

<h2>My_Domain<br />Our goal is to help…

<p>Call us anytime, yada yada</p><br />

<?php

$s = preg_replace(“/(.*)-(html|htm|php|asp|aspx)$/”,”$1″,$wp_query->query_vars[‘name’]);

$posts = query_posts(‘post_type=any&name=’.$s);

$s = str_replace(“-“,” “,$s);

if (count($posts) == 0) {

$posts = query_posts(‘post_type=any&s=’.$s);

}

if (count($posts) > 0) {

echo “<ol><li>”;

echo “<p>Were you looking for one of the following articles?</p>”;

echo “<ul>”;

foreach ($posts as $post) {

echo ‘<li><a href=”‘.get_permalink($post->ID).'”>’.$post->post_title.'</a></li>’;

}

echo “</ul>”;

echo “<p></p></li>”;

} else {

echo “<p></p>”;

echo “</ol><ol>”;

}

?>

<li>

<label for=”s”><strong>Search</strong> for it:

<form style=”display:inline;” action=”<?php bloginfo(‘siteurl’);?>”>

<input type=”text” value=”<?php echo esc_attr($s); ?/>” id=”s” name=”s”/> <input type=”submit” value=”Search”/>

</form>

</li>

</ol>

</div>

Grab the text above from Dropbox for a quick copy/paste:

https://dl.dropboxusercontent.com/u/2698469/404.txt

Then test your 404 page by going to http://your+domain/junktext

Suffice it to say, having a poorly coded or broken 404 page can cause a great deal of hurt SEO-wise if you don’t do this right…

Enjoy!

 

Like this:

Like Loading...

Filed Under: Call (619) 479-6637

Reader Interactions

Please feel free to comment via WordPress, Twitter, Facebook or Google+ Cancel reply

Proactive WordPress Security Management for Pennies a Day™

© Copyright 2022 HackGuard.com™, HackRepair.com™,
The Hack Repair Guy™, Hack Repair Guy™
Copyright and Trademark Statement | Privacy Policy

Call HackRepair.com for website security help, (619) 479-6637.
Content Approved By Jim Walker, The Hack Repair Guy
%d bloggers like this: