To completely disable this feature, use this code, which I got from here.
remove_action( 'template_redirect', 'redirect_canonical' );
To only disable it for URL addresses that contain the string ‘event’, use this code:
add_filter( 'redirect_canonical', 'disable_redirect_canonical_for_event', 2, 10 );
function disable_redirect_canonical_for_event( $redirect_url, $requested_url ) {
if ( strpos( $requested_url, 'event' ) !== false ) {
return false;
}
return $redirect_url;
}
Related Posts:
- How does WordPress handle permalinks?
- Removing the redirect after changing a page’s slug
- 301 Redirects for Changed Permalink Structure & Category Base
- URL rewrite based on a custom field value
- How can I force WordPress to redirect to canonical permalinks?
- Passing variables through permalink structure
- + Character in permalink
- Permalink redirection from ‘Day and name’ to ‘Post name’
- Nicest way to 301 Redirect traffic when changing permalink settings
- Changing pemalink structure to /%post_id%/%postname%/
- htaccess or redirect to cloak portion of a link?
- Redirect short-form URL to long-form URL (post_id to post_id + post_name)
- Auto 301 to full post permalink? (using /posts/%post_id%/%postname%)
- 301 Redirects for posts, category, pages from original domain to sub-domain of multisite
- WordPress on VirtualBox – no pretty permalinks
- Stop redirecting to posts not in a category / duplicate slugs
- Redirect old permalinks with Month and name to Post name on new site
- Does WordPress send a 301 header message when you change permalink structures?
- .htaccess – Redirect duplicated post ended in ‘-number/’ to the same url without the -number/
- Top level Pages redirecting to homepage!
- WordPress redirection problem after moving to a new server?
- Specific URL Rewriting with parameters in wordpress
- How to 301 all posts
- WordPress within specific sub-directories, implicitly not root
- Multisite Network: How to change permalink structure programmatically on new blogs
- Get canonical link
- Post incorrectly displaying as page
- wp_logout_url redirects to incorrect page because of pagination
- If I change permalink structures, can I use htaccess to permanantly redirect links?
- Redirect parent taxonomy to it’s child
- Infinite redirects after changing the permalink of a page
- Does rename of page slugs create 301 redirects from old slug to new (same as for posts)?
- Create unique alphanumeric ID on wp_insert_post
- Custom Permalink
- Redirect & permalink problems after moving multisite to a new server
- Changing the post date without causing 404 error
- Change permalinks on move from one site to another
- Redirects after permalink change
- How to 301 redirect from one url to another properly
- Redirect a Blogger Page URL to wordpress
- How to eliminate permalink prefix in WordPress Multisite
- Redirecting all posts after changing URL structure with htaccess
- Redirect all posts permalinks from “.html” to “/”
- WordPress 4.4 old permalink redirect
- Htaccess https 301 problem
- Passing the JQuery string to Worldpress URL
- How to use different domains for different blogs hosted in the same host in subdomains with .htaccess
- Freeze child page URLs so parent permalink changes don’t give 404s?
- Permalinks settings
- How can I make internal anchor links work with WordPress’s permalinks?
- Is it possible to install WordPress Multisite on a subdomain with subdirectories?
- What causes /pages/ to appear in URI, and how to remove it?
- Some Pemalink problems, probably caused by wrong .htaccess configuration?
- Test site pages go to main site
- Comment author url link is wrong? How to change from authors/ to author/
- Strange behavior with a redirect loop – involves WPML multi-language plugin
- Redirect From Url To Url
- I’ve removed my /author/ slug but it clashes with new and existing pages. Any fixes?
- Redirecting “wrong” but working links to their canonical URL in order to prevent search engine penalties (e.g. /123/ at the end of URLs)
- After cloning WP do a subdirectory, I can’t access it
- change WordPress permalinks and redirect new urls 301
- Arabic permalink redirect to home page
- Getting an ID from a URL, why can WP do this itself, but none of of the functions provided get it right?
- Custom permalink structure with %postname% in front of domain name
- Configuring Home Page Address
- new page redirect to old page which had the same permalink
- Change url of page according to my requirements in wordpress
- flush_rewrite_rules on MultiSite
- How to redirect old permalinks from https://exmaple.com/category/post_id to https://exmaple.com/category/post_id.html
- corrupted URLs – can’t leave starting page
- Find all URLs for a post
- where can i see wordpress automatic redirect History
- Redirect old /%category%/%postname%/ to just /%postname%/
- Extending page urls without getting a 404
- why wordpress keeps redirecting to old page after deleting it?
- Change permalink structure in all sites of a multisite
- 404 on wordpress multisite Permalink pretty URLs
- WordPress Multisite ABSPATH and get_home_path() to check for htaccess or web.config file
- 301 redirects after changing permalinks
- How to experiment with permalink structure on a select number of posts
- In a multisite, how can I get posts from one site and display their permalinks in another site?
- Change permalink structure with post id
- redirect any category in URL to the ID and post-name only – hundreds of pages affected
- Post redirected to page with same name but DIFFERENT permalink
- Changed Permalinks settings, how do I redirect posts on Nginx?
- Post permalinks go to the home page
- Can’t access WordPress site in subfolder possibly because of .htaccess redirect from root installation?
- changing permalink gives 404 error for old links
- All pages lead to home
- Removed and Reinstalled WordPress, Redirect Broken now
- redirect old pages by .htaccess
- Why are all pages redirecting to homepage when using custom permalinks?
- Redirecting From An Old Permalink Structure
- .htaccess regex for redirect subdomain to root domain & redirect old permalinks
- 301 Redirect posts to newly added categories
- Pages resolve at different URLs (different capitalizations)
- WordPress not remembering old slugs for pages
- Changing permalink won’t redirect to new version of page
- Removing /wp in Permalink URL of subdomain led to inaccessibility to WP Dashboard
- Permalinks and redirects