You can use conditional tag is_404()
and wp
action hook to redirect whenever the page can not be found.
functions.php
add_action( 'wp', 'se344018_redirect_404' );
function se344018_redirect_404()
{
if ( is_404() ) {
wp_redirect( home_url() );
//
// wp_redirect( home_url('some/page-slug') );
exit;
}
}
Related Posts:
- How to prevent automatic redirection of 404 errors and “incorrect” URLs?
- Disable WordPress URL auto complete
- Redirect user to original url after login?
- Disable ONLY URL auto complete, not the whole canonical URL system
- User redirect to destination URL after login
- Redirecting WordPress /.htaccess / HSTS / SSL
- Why does WordPress automatically redirect URLs with the parameter “name=” to a different page?
- How to setup 301 redirects for multiple query string URLs?
- Stop unwanted WP redirection to new url
- How does WordPress redirect to WooCommerce shop page? [closed]
- WP redirects all pages from new domain to old domain
- Does WordPress automatically redirect url without parent slug?
- How to redirect visitor to a custom URL using PHP code in functions.php
- Redirect home to another page with htaccess
- Why does wp_redirect strip out %0A (url encoded new line character) and how do I make it stop?
- How to redirect URL with subfolder to the same URL but without subfolder?
- How to redirect a page into file?
- How to redirect after login getting a variable from url (for example with the language)
- How can I replace my primary url globally with a parked one?
- URL redirect problem
- Adding rewrite rule dynamically for search results redirecting to 404 URL
- How to redirect to clean links with this code
- reducing number of URL Redirects and increasing speed
- URL masking of subdomain to main domain using .htaccess
- Disable WordPress URL auto complete
- Redirect user to original url after login?
- store URL global before we redirect
- WP_List_table with form of method=GET redirects to wrong url after submit
- Redirect old URL (with different post ID) to new URL
- How to fix automatic redirects?
- My redirect URL doesn’t show any pages on my website [closed]
- Preventing Canonical Redirect for CDN
- URL redirection
- URL redirect regular expressions redirecting all after first viriable
- Disable WordPress URL auto Redirect
- How to get user details by name
- Redirect only PDFs in different folders?
- How to disable WordPress URL autocomplete / recognition?
- using wp_rewrite but keep the original url in the address bar
- I’ve move my site but URL still goes to the old site
- Redirect based on $_GET parameters
- International characters in slugs to redirect to
- Rewrite rule for incoming urls
- URL Custom Rewrite
- How to handle expired assets/content when user has direct URL
- How to change Ugly link?
- Redirect ignore last URL segment
- Redirect to dashboard after login
- Make a video post redirect to next post after completion
- WordPress Redirect based on the prescence of a cookie
- Remove lost password form and URL
- How To Only Allow Users To View Their Own Buddypress Profiles? [closed]
- htaccess redirect dynamic posts
- Menu links only using http after enabling https, unable to redirect http links
- Redirect all pages to homepage but still allow dashboard
- some url does not redirect from http to https
- Why can’t I access files / directories outside of wordpress
- Redirect the non-www version of the site to the www
- How to set 301 redirection after moving WordPress blog?
- How to use a custom domain?
- Changing siteurl and homeurl – internal links redirect to home page?
- redirect Login problems
- 301 redirection editing .htaccess doesn’t work
- 301-redirect directives for blogger to wordpress migration
- Some admin pages redirecting to front page on save
- .htaccess 301 redirect conflict with plugin “WordPress Https”
- How do I put up a splash page and have all WordPress links redirect to this page?
- How can I disable author pages without 301 redirects?
- Redirect specific URL before other redirects take place in .htaccess?
- Redirect Main Home Page url to category URL without plugin
- Custom redirect user after login based on metadata
- wp_redirect () doesn’t work in nginx?
- Adding query string parameters to URL with same name as custom post type gives 404 error
- Display Freebie Page Content only if Referrer is from Form Page
- Create header.php redirect in WordPress and with WPML
- simple wordpress form redirection
- Redirect home resets (qtranslate) language
- wp_login_form redirect
- When i try to enter subdomain i’m redirected to main domain
- Change my URL from https://www.domain.com to https://domain.com
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- Need to redirect home page only on Woocommerce site if user logged in
- Redirect to dashboard user once you click on Publish page
- Author Archive Page redirecting issue
- Changing auth_redirect() page
- Why https://www. SUBdomain is redirected by WP to https://MAINdomain
- Redirect based on referer using Advanced Custom Fields
- How to redirect a referal url to a signup page?
- How to modify the WordPress comes with redirect
- Conditional redirect on login using referring URL
- Multisite hide subdirectory
- WordPress update 4.4.1 redirect loop
- How to redirect correctly a root domain to a subdomain in a subfolder?
- 301 redirect for wordpress permarlink
- login_redirect for Mobile Web
- Need rewrite for URL with specific string
- Redirect to 404.php from single.php
- How does the flow of htaccess files in sub-directories work
- Redirect to a subdirectory frontpage using without using a WP plugin- what files to edit, and how?
- How to Show different page URL instead of default home page URL