This is done by redirect_guess_404_permalink()
, which is called from redirect_canonical()
. redirect_canonical()
does more than just this: it makes sure you are always using a single canonical URL for an item, it will add slashes, force the same domain name, …
You can either unhook redirect_canoncial
so it does nothing, or you can hook into it and prevent redirection when it is a 404:
// Disable redirect_canonical()
add_action( 'init', 'wpse18110_init' );
function wpse18110_init()
{
remove_action( 'template_redirect', 'redirect_canonical' );
}
// Only prevent redirect on 404
add_filter( 'redirect_canonical', 'wpse18110_redirect_canonical' );
function wpse18110_redirect_canonical( $redirect_url )
{
if ( is_404() ) {
return false;
}
return $redirect_url;
}
Related Posts:
- How do I make a redirect in PHP?
- PHP – redirect https to http and www to non-www
- Redirect to Page after Post Submit
- How to redirect users to custom lostpassword page?
- Insert code when users come from an specific referer
- How to turn off redirection from ‘domain.com/login’ to ‘domain.com/wp-login.php’
- WordPress template_include filter not working properly
- Logout and redirect using the WP Menu
- Change links automatically to affiliate links
- PHP If user is logged in & on home page redirect
- Woocommerce redirect thankyou page based on product ID doesn’t empty Cart
- WordPress does not load page.php, return 404.php
- 3 blogs same installation, without WP MU
- WordPress homepage infinite redirect
- Redirect undesirable domain
- How do I display the main domain for my WordPress install?
- Problem with login form
- Set Cache-Control header for 301 redirects
- How to redirect users based on role and content of redirect_to?
- Moving code from theme header to functions.php
- Showing latest post without 301 redirect
- Having Issue on Redirecting With Session in WordPress
- Using a $GET parameter from a URL, to redirect to a URL (WordPress)
- WordPress redirect redirecting too many times or not at all
- Using Argument from Function to Re-Direct Visitor (WordPress)
- I am receiving a pluggable.php warning sign on my only http:// page
- Login redirect. Check user meta and redirect accordingly
- Where to insert redirect code based on http_referer?
- Is this a correct usage of ob_start() in my WordPress project?
- How to allow download url redirection only if user logged in WordPress site?
- PHP Redirect condition
- Manually Create PHP Page For A Redirect
- Redirect to current user page upon link click
- Ajax URLs without #!, how to prevent falling into single.php on load or reload?
- Writing a link cloaking plugin
- WordPress permalink issue
- WP insert post Redirect after function has executed
- How to redirect non logged in mobile users to page on same site?
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- Download file and redirect to page or vice versa
- Add more user roles to a PHP logout redirect function [closed]
- 404 on old link after changing post url
- WordPress url By country code?
- how can i redirect dynamic URL in worpress base on ID in htaccess or wp-config or function.php
- Implementing a multilingual WordPress site by installing several instances of WordPress and redirecting
- WordPress on Ubuntu – “File not Found” for home.php – Trying to Redirect to Root Folder
- Remove all feeds and return custom 404 page
- Infinite loop when logging out using custom login form
- Redirect User when they click Menu Option
- WordPress: Redirect Main Site to Subsite in Multisite Where user is NOT logged in
- Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
- wp-login.php?redirect_to=https problem
- ERR_TOO_MANY_REDIRECTS / To Force SSL Logins and SSL Admin Access
- WordPress Redirect / Add_Rewrite_Rule – Non Index.php Page
- Override 404 when navigating to single php file
- Submit to itself don’t work
- redirect 301 with special character like WIX site “#!”
- 301 redirect from webpage to wordpress page in the same root
- Submitting my form to the database and then redirecting to payment site
- 3 domains, 1 wordpress install, redirecting and changing domains on live site
- Get permalink for a post from inside WordPress and route to a related site
- Redirect users not logged in to the standard login page (and back) from some posts and pages
- Link to external page has wordpress blog-url inside
- How to use multiple 404 Error Pages in WordPress
- How to create a WordPress PAGE in another folder?
- index.php file keeps redirecting to a non-existent index.html file?
- Redirect loop upon installation of my plugin
- wp_login_url always redirects me to wp-admin
- Is there a way for a plugin to add an attribute to the tag of a theme?
- wp_set_object_terms and arrays
- WordPress 4 invalid username special charachters issue
- How to remove this function from the homepage?
- Nested shortCode functions in the functions.php file
- How to display posts of specific category using a custom Query in WordPress?
- Create placeholder text for wordpress search box [closed]
- Woocommerce product variation backorder
- Calculating a large number of MYSQL queries as customshort codes, slow
- Status 400 for AJAX POST Request with admin-ajax.php
- Cannot execute php files in wp-content
- Make Current/Active Page Number a Link (WP_LINK_PAGES)
- How to show number of unpublished articles?
- How to retrieve the data from the sever and displaying it in a page?
- Javascript not loading on certain page
- Display WordPress Post on A Different Site
- Add row to custom database Table and delete all rows older than 1 day
- PHP: $_SESSION destroyed after page reload for my custom session
- problem connecting to the administrator
- Looping through dummy posts and showing them in the main index.php
- PHP – Woocommerce 3.2 Add variable shipping insurance with multiple “else if ” conditions
- Shortcode Works for Logged in Users but Not Working for Guest
- Fix mod_pagespeed Fetch timed out error on bitnami AWS wordpress installation
- Adding my own custom template page but got white page
- WordPress will suddenly stop saving files uploaded by my code (ran in nopriv ajax)
- Adding javascript files to WordPress and jQuery version
- Display default WordPress login/registration form into a modal window
- WP Login Button for current domain
- Pull GET parameter from URL in functions.php
- How to NOT override inline css rules
- duplicating page templates
- Upload multiple files via ajax from an HTML file input