Version Description
- added filter to "skip" WP Admin, cron, and XML-RPC requests
- updated recommended plugins
Download this release
Release Info
Developer | littlebizzy |
Plugin | Redirect 404 To Homepage |
Version | 1.0.6 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.0.6
- 404-to-homepage.php +29 -24
- admin-notices.php +283 -0
- readme.txt +75 -39
404-to-homepage.php
CHANGED
@@ -1,28 +1,14 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: 404 To Homepage
|
4 |
-
Plugin URI: https://www.littlebizzy.com/
|
5 |
-
Description: 404
|
6 |
-
Version: 1.0
|
7 |
Author: LittleBizzy
|
8 |
Author URI: https://www.littlebizzy.com
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
the Free Software Foundation; either version 2 of the License, or
|
13 |
-
(at your option) any later version.
|
14 |
-
|
15 |
-
This program is distributed in the hope that it will be useful,
|
16 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
-
GNU General Public License for more details.
|
19 |
-
|
20 |
-
You should have received a copy of the GNU General Public License
|
21 |
-
along with this program; if not, write to the Free Software
|
22 |
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
23 |
-
|
24 |
-
Copyright 2016 by LittleBizzy
|
25 |
-
|
26 |
*/
|
27 |
|
28 |
|
@@ -35,18 +21,25 @@ if (!function_exists('add_action'))
|
|
35 |
// This plugin constants
|
36 |
define('NTFTHP_FILE', __FILE__);
|
37 |
define('NTFTHP_PATH', dirname(NTFTHP_FILE));
|
38 |
-
define('NTFTHP_VERSION', '1.0');
|
39 |
|
40 |
|
41 |
/* 404 hooks */
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
/**
|
44 |
* Early method to detect 404 context
|
45 |
* Minimum WP version: 4.5.0
|
46 |
*/
|
47 |
add_filter('pre_handle_404', 'ntfthp_pre_handle_404', 0, 2);
|
48 |
function ntfthp_pre_handle_404($preempt, $wp_query) {
|
49 |
-
if ($wp_query->is_404()) {
|
50 |
require_once(NTFTHP_PATH.'/404-redirect.php');
|
51 |
NTFTHP_Redirect::go();
|
52 |
}
|
@@ -59,8 +52,20 @@ function ntfthp_pre_handle_404($preempt, $wp_query) {
|
|
59 |
*/
|
60 |
add_action('wp', 'ntfthp_wp');
|
61 |
function ntfthp_wp() {
|
62 |
-
if (is_404()) {
|
63 |
require_once(NTFTHP_PATH.'/404-redirect.php');
|
64 |
NTFTHP_Redirect::go();
|
65 |
}
|
66 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: 404 To Homepage
|
4 |
+
Plugin URI: https://www.littlebizzy.com/plugins/404-to-homepage
|
5 |
+
Description: Redirects all 404 (Not Found) errors to the homepage for a better user experience, less abuse from bots, and 100% elimination of Google GSC warnings.
|
6 |
+
Version: 1.0.6
|
7 |
Author: LittleBizzy
|
8 |
Author URI: https://www.littlebizzy.com
|
9 |
+
License: GPLv3
|
10 |
+
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
+
Prefix: NTFTHP
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
*/
|
13 |
|
14 |
|
21 |
// This plugin constants
|
22 |
define('NTFTHP_FILE', __FILE__);
|
23 |
define('NTFTHP_PATH', dirname(NTFTHP_FILE));
|
24 |
+
define('NTFTHP_VERSION', '1.0.6');
|
25 |
|
26 |
|
27 |
/* 404 hooks */
|
28 |
|
29 |
+
/**
|
30 |
+
* Front-end function check
|
31 |
+
*/
|
32 |
+
function ntfthp_is_frontend() {
|
33 |
+
return is_admin()? false : !((defined('DOING_CRON') && DOING_CRON) || (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST));
|
34 |
+
}
|
35 |
+
|
36 |
/**
|
37 |
* Early method to detect 404 context
|
38 |
* Minimum WP version: 4.5.0
|
39 |
*/
|
40 |
add_filter('pre_handle_404', 'ntfthp_pre_handle_404', 0, 2);
|
41 |
function ntfthp_pre_handle_404($preempt, $wp_query) {
|
42 |
+
if ($wp_query->is_404() && ntfthp_is_frontend()) {
|
43 |
require_once(NTFTHP_PATH.'/404-redirect.php');
|
44 |
NTFTHP_Redirect::go();
|
45 |
}
|
52 |
*/
|
53 |
add_action('wp', 'ntfthp_wp');
|
54 |
function ntfthp_wp() {
|
55 |
+
if (is_404() && ntfthp_is_frontend()) {
|
56 |
require_once(NTFTHP_PATH.'/404-redirect.php');
|
57 |
NTFTHP_Redirect::go();
|
58 |
}
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
/* Plugin suggestions */
|
63 |
+
|
64 |
+
// Admin loader
|
65 |
+
if (is_admin()) {
|
66 |
+
$timestamp = (int) get_option('ntfhp_dismissed_on');
|
67 |
+
if (empty($timestamp) || (time() - $timestamp) > (180 * 86400)) {
|
68 |
+
require_once(NTFTHP_PATH.'/admin-notices.php');
|
69 |
+
NTFTHP_Admin_Suggestions::instance();
|
70 |
+
}
|
71 |
+
}
|
admin-notices.php
ADDED
@@ -0,0 +1,283 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* 404 To Homepage - Plugins Suggestions class
|
5 |
+
*
|
6 |
+
* @package 404 To Homepage
|
7 |
+
* @subpackage 404 To Homepage Admin
|
8 |
+
*/
|
9 |
+
final class NTFTHP_Admin_Suggestions {
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
// Properties
|
14 |
+
// ---------------------------------------------------------------------------------------------------
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Single class instance
|
20 |
+
*/
|
21 |
+
private static $instance;
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Plugins directories
|
27 |
+
*/
|
28 |
+
private $missing;
|
29 |
+
private $required = array(
|
30 |
+
'remove-query-strings-littlebizzy' => array(
|
31 |
+
'name' => 'Remove Query Strings',
|
32 |
+
'desc' => 'Removes all query strings from static resources meaning that proxy servers and beyond can better cache your site content (plus, better SEO scores).',
|
33 |
+
'filename' => 'remove-query-strings.php',
|
34 |
+
),
|
35 |
+
'remove-category-base-littlebizzy' => array(
|
36 |
+
'name' => 'Remove Category Base',
|
37 |
+
'desc' => 'Completely disables the category base from all URLs generated by WordPress so that there is no category slug displayed on archive permalinks, etc.',
|
38 |
+
'filename' => 'remove-category-base.php',
|
39 |
+
),
|
40 |
+
'force-https-littlebizzy' => array(
|
41 |
+
'name' => 'Force HTTPS',
|
42 |
+
'desc' => 'Redirects all HTTP requests to the HTTPS version and fixes all insecure static resources by implementing relative URLs without altering the database.',
|
43 |
+
'filename' => 'force-https.php',
|
44 |
+
),
|
45 |
+
'disable-emojis-littlebizzy' => array(
|
46 |
+
'name' => 'Disable Emojis',
|
47 |
+
'desc' => 'Completely disables both the old and new versions of WordPress emojis, removes the corresponding javascript calls, and improves page loading times.',
|
48 |
+
'filename' => 'disable-emojis.php',
|
49 |
+
),
|
50 |
+
'server-status-littlebizzy' => array(
|
51 |
+
'name' => 'Server Status',
|
52 |
+
'desc' => 'Useful statistics about the server OS, CPU, RAM, load average, memory usage, IP address, hostname, timezone, disk space, PHP, MySQL, caches, etc.',
|
53 |
+
'filename' => 'server-status.php',
|
54 |
+
),
|
55 |
+
);
|
56 |
+
|
57 |
+
|
58 |
+
|
59 |
+
// Initialization
|
60 |
+
// ---------------------------------------------------------------------------------------------------
|
61 |
+
|
62 |
+
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Create or retrieve instance
|
66 |
+
*/
|
67 |
+
public static function instance() {
|
68 |
+
|
69 |
+
// Check instance
|
70 |
+
if (!isset(self::$instance))
|
71 |
+
self::$instance = new NTFTHP_Admin_Suggestions;
|
72 |
+
|
73 |
+
// Done
|
74 |
+
return self::$instance;
|
75 |
+
}
|
76 |
+
|
77 |
+
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Constructor
|
81 |
+
*/
|
82 |
+
private function __construct() {
|
83 |
+
|
84 |
+
// Check AJAX submit
|
85 |
+
if (defined('DOING_AJAX') && DOING_AJAX) {
|
86 |
+
add_action( 'wp_ajax_ntfhp_dismiss', array(&$this, 'dismiss'));
|
87 |
+
|
88 |
+
// Admin area (except install or activate plugins page)
|
89 |
+
} elseif (!in_array(basename($_SERVER['PHP_SELF']), array('plugins.php', 'plugin-install.php', 'update.php'))) {
|
90 |
+
|
91 |
+
// Admin hooks
|
92 |
+
add_action('admin_footer', array(&$this, 'admin_footer'));
|
93 |
+
add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Footer script
|
101 |
+
*/
|
102 |
+
public function admin_footer() { ?>
|
103 |
+
<script type="text/javascript">jQuery(function($) { $(document).on('click', '.ntfhp-dismiss .notice-dismiss', function() { $.post(ajaxurl, {'action':'ntfhp_dismiss','nonce':$(this).parent().attr('data-nonce')}); }); });</script>
|
104 |
+
<?php }
|
105 |
+
|
106 |
+
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Dismissi timestamp
|
110 |
+
*/
|
111 |
+
public function dismiss() {
|
112 |
+
if (!empty($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], NTFTHP_FILE.'-dismiss'))
|
113 |
+
update_option('ntfhp_dismissed_on', time(), true);
|
114 |
+
}
|
115 |
+
|
116 |
+
|
117 |
+
|
118 |
+
// Plugins check
|
119 |
+
// ---------------------------------------------------------------------------------------------------
|
120 |
+
|
121 |
+
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Admin notices
|
125 |
+
*/
|
126 |
+
public function admin_notices() {
|
127 |
+
|
128 |
+
?><div class="ntfhp-dismiss notice notice-success is-dismissible" data-nonce="<?php echo wp_create_nonce(NTFTHP_FILE.'-dismiss'); ?>">
|
129 |
+
|
130 |
+
<p>404 To Homepage recommends the following free plugins:</p>
|
131 |
+
|
132 |
+
<ul><?php foreach ($this->missing as $plugin) : ?>
|
133 |
+
|
134 |
+
<li><strong><?php echo $this->required[$plugin]['name']; ?></strong> <a href="<?php echo esc_url($this->get_install_url($plugin)); ?>">Install now!</a><br /><?php echo $this->required[$plugin]['desc']; ?></li>
|
135 |
+
|
136 |
+
<?php endforeach; ?></ul>
|
137 |
+
|
138 |
+
</div><?php
|
139 |
+
}
|
140 |
+
|
141 |
+
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Check current active plugins
|
145 |
+
*/
|
146 |
+
public function plugins_loaded() {
|
147 |
+
|
148 |
+
// Check missing plugins
|
149 |
+
$this->missing = $this->get_missing_plugins();
|
150 |
+
if (empty($this->missing) || !is_array($this->missing))
|
151 |
+
return;
|
152 |
+
|
153 |
+
// Notice action
|
154 |
+
add_action('admin_notices', array(&$this, 'admin_notices'));
|
155 |
+
}
|
156 |
+
|
157 |
+
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Retrieve uninstalled plugins
|
161 |
+
*/
|
162 |
+
private function get_missing_plugins() {
|
163 |
+
|
164 |
+
// Initialize
|
165 |
+
$inactive = array();
|
166 |
+
|
167 |
+
// Check plugins directory
|
168 |
+
$directories = array_merge(self::get_mu_plugins_directories(), self::get_plugins_directories());
|
169 |
+
if (!empty($directories)) {
|
170 |
+
$required = array_keys($this->required);
|
171 |
+
foreach ($required as $plugin) {
|
172 |
+
if (!in_array($plugin, $directories))
|
173 |
+
$inactive[] = $plugin;
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
// Check inactives
|
178 |
+
if (empty($inactive))
|
179 |
+
return false;
|
180 |
+
|
181 |
+
// Done
|
182 |
+
return $inactive;
|
183 |
+
}
|
184 |
+
|
185 |
+
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Collects all active plugins
|
189 |
+
*/
|
190 |
+
private function get_plugins_directories() {
|
191 |
+
|
192 |
+
// Initialize
|
193 |
+
$directories = array();
|
194 |
+
|
195 |
+
// Plugins split directory
|
196 |
+
$split = '/'.basename(WP_CONTENT_DIR).'/'.basename(WP_PLUGIN_DIR).'/';
|
197 |
+
|
198 |
+
// Multisite plugins
|
199 |
+
if (is_multisite()) {
|
200 |
+
$ms_plugins = wp_get_active_network_plugins();
|
201 |
+
if (!empty($ms_plugins) && is_array($ms_plugins)) {
|
202 |
+
foreach ($ms_plugins as $file) {
|
203 |
+
$directory = explode($split, $file);
|
204 |
+
$directory = explode('/', ltrim($directory[1], '/'));
|
205 |
+
$directory = $directory[0];
|
206 |
+
if (!in_array($directory, $directories))
|
207 |
+
$directories[] = $directory;
|
208 |
+
}
|
209 |
+
}
|
210 |
+
}
|
211 |
+
|
212 |
+
// Active plugins
|
213 |
+
$plugins = wp_get_active_and_valid_plugins();
|
214 |
+
if (!empty($plugins) && is_array($plugins)) {
|
215 |
+
foreach ($plugins as $file) {
|
216 |
+
$directory = explode($split, $file);
|
217 |
+
$directory = explode('/', ltrim($directory[1], '/'));
|
218 |
+
$directory = $directory[0];
|
219 |
+
if (!in_array($directory, $directories))
|
220 |
+
$directories[] = $directory;
|
221 |
+
}
|
222 |
+
}
|
223 |
+
|
224 |
+
// Done
|
225 |
+
return $directories;
|
226 |
+
}
|
227 |
+
|
228 |
+
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Retrieve mu-plugins directories
|
232 |
+
*/
|
233 |
+
private function get_mu_plugins_directories() {
|
234 |
+
|
235 |
+
// Initialize
|
236 |
+
$directories = array();
|
237 |
+
|
238 |
+
// Dependencies
|
239 |
+
if (!function_exists('get_plugins'))
|
240 |
+
require_once(ABSPATH.'wp-admin/includes/plugin.php');
|
241 |
+
|
242 |
+
// Retrieve mu-plugins
|
243 |
+
$plugins = get_plugins('/../mu-plugins');
|
244 |
+
if (!empty($plugins) && is_array($plugins)) {
|
245 |
+
foreach ($plugins as $path => $info) {
|
246 |
+
$directory = dirname($path);
|
247 |
+
if (!in_array($directory, array('.', '..')))
|
248 |
+
$directories[] = $directory;
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
// Done
|
253 |
+
return $directories;
|
254 |
+
}
|
255 |
+
|
256 |
+
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Plugin install/activate URL
|
260 |
+
*/
|
261 |
+
private function get_install_url($plugin) {
|
262 |
+
|
263 |
+
// Check existing plugin
|
264 |
+
$exists = @file_exists(WP_PLUGIN_DIR.'/'.$plugin);
|
265 |
+
|
266 |
+
// Activate
|
267 |
+
if ($exists) {
|
268 |
+
|
269 |
+
// Existing plugin
|
270 |
+
$path = $plugin.'/'.$this->required[$plugin]['filename'];
|
271 |
+
return admin_url('plugins.php?action=activate&plugin='.$path.'&_wpnonce='.wp_create_nonce('activate-plugin_'.$path));
|
272 |
+
|
273 |
+
// Install
|
274 |
+
} else {
|
275 |
+
|
276 |
+
// New plugin
|
277 |
+
return admin_url('update.php?action=install-plugin&plugin='.$plugin.'&_wpnonce='.wp_create_nonce('install-plugin_'.$plugin));
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
|
282 |
+
|
283 |
+
}
|
readme.txt
CHANGED
@@ -1,62 +1,88 @@
|
|
1 |
-
=== 404 To Homepage ===
|
|
|
2 |
Contributors: littlebizzy
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
Stable tag: 1.0
|
8 |
-
License:
|
9 |
-
License URI: http://www.gnu.org/licenses/gpl-
|
|
|
10 |
|
11 |
Redirects all 404 (Not Found) errors to the homepage for a better user experience, less abuse from bots, and 100% elimination of Google GSC warnings.
|
12 |
|
13 |
== Description ==
|
14 |
|
|
|
|
|
15 |
404 To Homepage is a simple WordPress plugin for redirecting all 404 "Not Found" errors to the homepage. The reason for doing this is to avoid user confusion (or lost leads), and to avoid abuse causes by bots that ping your site with non-existent URLs which can negatively effect search engine indexing. Additionally, it can totally eliminate the warnings created in Google GSC (Webmasters) in regard to 404 errors that begin piling up over time, which quite often are not even the fault of your website.
|
16 |
|
17 |
It should be noted, however, that this method is not recommended for all websites. For example, large blogs or magazines that rely heavily on search engine traffic (such as a newspaper) should probably not use this plugin. This is because in many cases, 404 errors should be analyzed on a regular basis and then 301 redirected to the appropriate page. Rather, this plugin is best suited for small businesses or websites with a limited amount of content, and limited staff, who are not publishing massive amounts of content. In such cases, we suggest monitoring 404 errors for perhaps a few months, redirecting the ones that are legitimate, and then consider activating this plugin after that point.
|
18 |
|
19 |
Unlike other 404 redirect plugins, 404 To Homepage "removes" any pre-existing HTTP headers, and executes ONLY a 301 redirect header pointed at the site's homepage. In other words, it does not allow any "previous" headers to be sent in order to avoid confusing browsers or Google bots. (NOTE: while any previous headers sent by WordPress/PHP engine are ignored, it's possible for your server i.e. Apache or Nginx to override things with header rules of their own... please check to ensure no conflicts.)
|
20 |
|
21 |
-
|
|
|
|
|
22 |
|
23 |
-
|
24 |
-
* __SERVER:__ Apache, Nginx
|
25 |
-
* __PHP:__ 5.5+
|
26 |
-
* __DATABASE:__ MySQL
|
27 |
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
* __MUST-USE:__ Supported
|
32 |
-
* __MULTI-SITE:__ Support unknown
|
33 |
-
* __TRANSIENTS:__ None
|
34 |
-
* __WP_OPTIONS:__ None
|
35 |
-
* __LOCALIZATION:__ None
|
36 |
-
* __UNINSTALL:__ Removes plugin files only (no stored data exists)
|
37 |
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
-
|
41 |
-
* HTTP header experimentation
|
42 |
-
* More features (based on user suggestions)
|
43 |
-
* Code maintenance/improvements
|
44 |
|
45 |
-
|
46 |
|
47 |
* [All 404 Redirect to Homepage](https://wordpress.org/plugins/all-404-redirect-to-homepage/)
|
48 |
* [404 Redirection](https://wordpress.org/plugins/404-redirection/)
|
49 |
* [Redirect 404 Error Page to Homepage](https://wordpress.org/plugins/redirect-404-error-page-to-homepage/)
|
50 |
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
== Installation ==
|
54 |
|
55 |
-
1. Upload
|
56 |
-
2. Activate
|
57 |
3. Test the plugin is working correctly by loading a non-existent URL of your website
|
58 |
|
59 |
-
==
|
60 |
|
61 |
= Does this plugin alter my 404.php template? =
|
62 |
|
@@ -70,17 +96,27 @@ This plugin does not have a settings page and is designed for speed and simplici
|
|
70 |
|
71 |
Please avoid leaving negative reviews in order to get a feature implemented. Instead, we kindly ask that you post your feedback on the wordpress.org support forums by tagging this plugin in your post. If needed, you may also contact our homepage.
|
72 |
|
73 |
-
== Screenshots ==
|
74 |
-
|
75 |
== Changelog ==
|
76 |
|
77 |
-
= 1.0 =
|
78 |
-
*
|
|
|
79 |
|
80 |
-
|
|
|
81 |
|
82 |
-
|
|
|
83 |
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
-
|
|
1 |
+
=== Redirect 404 To Homepage ===
|
2 |
+
|
3 |
Contributors: littlebizzy
|
4 |
+
Tags: 404, homepage, home, not found, errors, page, missing, 301, redirect, htaccess
|
5 |
+
Requires at least: 4.4
|
6 |
+
Tested up to: 4.8
|
7 |
+
Requires PHP: 7.0
|
8 |
+
Stable tag: 1.0.6
|
9 |
+
License: GPLv3
|
10 |
+
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
+
Prefix: NTFTHP
|
12 |
|
13 |
Redirects all 404 (Not Found) errors to the homepage for a better user experience, less abuse from bots, and 100% elimination of Google GSC warnings.
|
14 |
|
15 |
== Description ==
|
16 |
|
17 |
+
Redirects all 404 (Not Found) errors to the homepage for a better user experience, less abuse from bots, and 100% elimination of Google GSC warnings.
|
18 |
+
|
19 |
404 To Homepage is a simple WordPress plugin for redirecting all 404 "Not Found" errors to the homepage. The reason for doing this is to avoid user confusion (or lost leads), and to avoid abuse causes by bots that ping your site with non-existent URLs which can negatively effect search engine indexing. Additionally, it can totally eliminate the warnings created in Google GSC (Webmasters) in regard to 404 errors that begin piling up over time, which quite often are not even the fault of your website.
|
20 |
|
21 |
It should be noted, however, that this method is not recommended for all websites. For example, large blogs or magazines that rely heavily on search engine traffic (such as a newspaper) should probably not use this plugin. This is because in many cases, 404 errors should be analyzed on a regular basis and then 301 redirected to the appropriate page. Rather, this plugin is best suited for small businesses or websites with a limited amount of content, and limited staff, who are not publishing massive amounts of content. In such cases, we suggest monitoring 404 errors for perhaps a few months, redirecting the ones that are legitimate, and then consider activating this plugin after that point.
|
22 |
|
23 |
Unlike other 404 redirect plugins, 404 To Homepage "removes" any pre-existing HTTP headers, and executes ONLY a 301 redirect header pointed at the site's homepage. In other words, it does not allow any "previous" headers to be sent in order to avoid confusing browsers or Google bots. (NOTE: while any previous headers sent by WordPress/PHP engine are ignored, it's possible for your server i.e. Apache or Nginx to override things with header rules of their own... please check to ensure no conflicts.)
|
24 |
|
25 |
+
This is a version that uses the early WP hook 'pre_handle_404' to avoid unnecessary code execution (posts types creation and taxonomies). But this hook is available only from WP 4.5.0, so the plugin declares also the 'wp' standard hook just in case for older versions.
|
26 |
+
|
27 |
+
Before to do the redirection to the homepage, there is a procedure that removes any existing previous header, so only 301 header will be sent in response to the HTTP request. You can see the headers in chrome from Network tab and checking preserve log. For Firefox you can use the Live HTTP headers addon, for example.
|
28 |
|
29 |
+
#### Compatibility ####
|
|
|
|
|
|
|
30 |
|
31 |
+
This plugin has been designed for use on LEMP (Nginx) web servers with PHP 7.0 and MySQL 5.7 to achieve best performance. All of our plugins are meant for single site WordPress installations only; for both performance and security reasons, we highly recommend against using WordPress Multisite for the vast majority of projects.
|
32 |
|
33 |
+
#### Plugin Features ####
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
+
* Settings Page: No
|
36 |
+
* PRO Version Available: No
|
37 |
+
* Includes Media: No
|
38 |
+
* Includes CSS: No
|
39 |
+
* Database Storage: No
|
40 |
+
* Transients: No
|
41 |
+
* Options: Yes
|
42 |
+
* Database Queries: None
|
43 |
+
* Must-Use Support: Yes
|
44 |
+
* Multisite Support: No
|
45 |
+
* Uninstalls Data: Yes
|
46 |
|
47 |
+
#### Code Inspiration ####
|
|
|
|
|
|
|
48 |
|
49 |
+
This plugin was partially inspired either in "code or concept" by the open-source software and discussions mentioned below:
|
50 |
|
51 |
* [All 404 Redirect to Homepage](https://wordpress.org/plugins/all-404-redirect-to-homepage/)
|
52 |
* [404 Redirection](https://wordpress.org/plugins/404-redirection/)
|
53 |
* [Redirect 404 Error Page to Homepage](https://wordpress.org/plugins/redirect-404-error-page-to-homepage/)
|
54 |
|
55 |
+
#### Recommended Plugins ####
|
56 |
+
|
57 |
+
We invite you to check out a few other related free plugins that our team has also produced that you may find especially useful:
|
58 |
+
|
59 |
+
* [Remove Query Strings](https://wordpress.org/plugins/remove-query-strings-littlebizzy/)
|
60 |
+
* [Remove Category Base](https://wordpress.org/plugins/remove-category-base-littlebizzy/)
|
61 |
+
* [Force HTTPS](https://wordpress.org/plugins/force-https-littlebizzy/)
|
62 |
+
* [Disable Emojis](https://wordpress.org/plugins/disable-emojis-littlebizzy/)
|
63 |
+
* [Server Status](https://wordpress.org/plugins/server-status-littlebizzy/)
|
64 |
+
|
65 |
+
#### Special Thanks ####
|
66 |
+
|
67 |
+
We thank the following groups for their generous contributions to the WordPress community which have particularly benefited us in developing our own free plugins and paid services:
|
68 |
+
|
69 |
+
* [Automattic](https://automattic.com)
|
70 |
+
* [Delicious Brains](https://deliciousbrains.com)
|
71 |
+
* [Roots](https://roots.io)
|
72 |
+
* [rtCamp](https://rtcamp.com)
|
73 |
+
* [WP Tavern](https://wptavern.com)
|
74 |
+
|
75 |
+
#### Disclaimer ####
|
76 |
+
|
77 |
+
We released this plugin in response to our managed hosting clients asking for better access to their server, and our primary goal will remain supporting that purpose. Although we are 100% open to fielding requests from the WordPress community, we kindly ask that you keep the above mentioned goals in mind, thanks!
|
78 |
|
79 |
== Installation ==
|
80 |
|
81 |
+
1. Upload to `/wp-content/plugins/404-to-homepage-littlebizzy`
|
82 |
+
2. Activate via WP Admin > Plugins
|
83 |
3. Test the plugin is working correctly by loading a non-existent URL of your website
|
84 |
|
85 |
+
== FAQ ==
|
86 |
|
87 |
= Does this plugin alter my 404.php template? =
|
88 |
|
96 |
|
97 |
Please avoid leaving negative reviews in order to get a feature implemented. Instead, we kindly ask that you post your feedback on the wordpress.org support forums by tagging this plugin in your post. If needed, you may also contact our homepage.
|
98 |
|
|
|
|
|
99 |
== Changelog ==
|
100 |
|
101 |
+
= 1.0.6 =
|
102 |
+
* added filter to "skip" WP Admin, cron, and XML-RPC requests
|
103 |
+
* updated recommended plugins
|
104 |
|
105 |
+
= 1.0.5 =
|
106 |
+
* updated recommended plugins
|
107 |
|
108 |
+
= 1.0.4 =
|
109 |
+
* minor code tweaks
|
110 |
|
111 |
+
= 1.0.3 =
|
112 |
+
* added recommended plugin notices
|
113 |
+
|
114 |
+
= 1.0.2 =
|
115 |
+
* updated plugin meta
|
116 |
+
* tested with WordPress 4.8
|
117 |
+
|
118 |
+
= 1.0.1 =
|
119 |
+
* updated plugin meta
|
120 |
|
121 |
+
= 1.0.0 =
|
122 |
+
* initial release
|