URL rewriting not working

Just use this rewrite rule in your htaccess file, it will strip all query strings. RewriteRule ^(.*) /$1? [R=301,L] to allow more rules to follow use this instead RewriteRule ^(.*) /$1? [R=301] remove 301 like this RewriteRule ^(.*) /$1? [NE,L] and refer the correct url for search engines. without 301 you will need to make … Read more

Force search form to go to clean url without multiple redirects

Assuming you make your form’s action point to the correct URL, here are Two (and a half) Options: With Javascript (jQuery) jQuery(document).ready( function() { jQuery(“#searchform”).submit( function() { self.location.href = jQuery(this).attr(“action”) + jQuery(“#s”).val(); return false; }); }); You could also do it without jQuery (if you don’t use jQuery on your site and don’t want to … Read more

WPML language switcher for custom rewrite rules

A more simple solution for generating the rewrite rules would be to temporarily disable the WPML plugin. I did this using WP-CLI as follows: wp plugin deactivate sitepress-multilingual-cms wp rewrite flush wp plugin activate sitepress-multilingual-cms Note that this only works a single time. Each time you add/modify a category, the rewrite list is flushed and … Read more

Custom rewrite causes 404 on pagination

If anyone still has this issue (this post is quite old), I found a very helpful snippet in this blog post: https://www.grzegorowski.com/wordpress-rewrite-rules /** * Reprioritise pagination over displaying custom post type content */ add_action(‘init’, function() { add_rewrite_rule(‘(.?.+?)/page/?([0-9]{1,})/?$’, ‘index.php?pagename=$matches[1]&paged=$matches[2]’, ‘top’); }); This will ensure WP uses the pagination rule prior to the post type query rules