How do I bypass WordPress 404 handling?

If you have a non-static request like: example.tld/some-slug/ then you will need to run WordPress to see if that slug is available. The webserver (nginx/apache) doesn’t know that, because WordPress will have to inform us about that through the 404 response header. If your site has only few pages, then you could tell the webserver … Read more

404 to 301 – Fixing old links

If you intend to do checks based on template tags you should hook on wp action. template_redirect will suffice too, but wp is earlier. This is when WP handles 404 itself. To perform a 301 redirect use status_header( 301 );, wp_safe_redirect(); immediately followed by exit; You could use a plugin handle these for you. It’s … Read more

“Lost password” page triggers 404

Your theme or plugins are most likely modifying the “Lost password” link on your wp-login.php via the lostpassword_url filter. How do I reset the “change password” page to the WP default one? One would need to remove those filters callbacks. Here’s one (untested) suggestion: add_filter( ‘lostpassword_url’, function( $url, $redirect ) { remove_all_filters( ‘lostpassword_url’ ); return … Read more

page not found in Chrome, but found in Firefox

You are sending a very confusing response: HTTP/1.1 301 Moved Permanently Date: Sat, 20 Oct 2012 12:33:06 GMT Server: Apache X-Powered-By: PHP/5.3.13 X-Pingback: http://tech.doig.com.au/xmlrpc.php Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/html; charset=UTF-8 After that the regular page content follows. So in your first line you tell the browser to look elsewhere for the content. But … Read more

Where is the best part to hijack or catch a potential 404

It’s not possible to catch a non–match to template in WP because it will always match some template. The very last template it will fall back to will simply be index.php, the most generic one in template hierarchy. In general the appropriate hook for such logic is typically template_redirect in template-loader.php. At this point the … Read more

404 error on all pages but homepage

Assuming you are on Linux, you need to make some changes in apache2.conf file stored in /etc/apache2 directory. Open the file with root permissions, you will find the code given below in the file. <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> Here just change the AllowOverride None to AllowOverride All, save … Read more