I have set a post to private on a WordPress multisite so users should be redirected to a 404 page. The permalink of this post is http://local.website.com/en/event.

Now WordPress seems to redirect requests to event to event-30-01-2016. WordPress seems to focus on the lower number after the event string. Example: it will prioritise event-29-05-2015 over event-30-05-2015.

I want to keep the URLs for posts like event-* but I want event to redirect to 404 since I kind of disabled the page.

My settings on /wp-admin/options-permalink.php are set to Post name.

I don't have any special rewriteRules in .htaccess for events.

This is my .htaccess:

# BEGIN WordPress
RewriteEngine on
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
# END WordPress

Is there maybe a hook that I could use in order to disable this kind of redirection?

  • Try this wordpress.stackexchange.com/questions/71927/…
    – Nikolay
    Commented Nov 28, 2018 at 18:42
  • @Nikolay oh.. thank you a lot! I'll add the script in the answer that helped me. Or maybe you would like to answer the question? remove_action('template_redirect', 'redirect_canonical'); helped me
    – zyrup
    Commented Nov 28, 2018 at 20:42
  • You don’t want to completely remove canonical redirection! Check for your specific case and only remove it for those requests.
    – Milo
    Commented Nov 28, 2018 at 22:52

1 Answer 1


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;
  • It’s a bad idea to completely disable canonical redirection, which could result in SEO issues. You should check for the specific case you want to disable.
    – Milo
    Commented Nov 28, 2018 at 22:50
  • @Milo OK, I added another solution too now.
    – Nikolay
    Commented Nov 29, 2018 at 5:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.