lundi 15 décembre 2014

How to stop permalink redirects for a particular slug


I have a large number of posts that each represent a very specific type of data. Each post title is the SKU for the data & information. Folks have become pretty savvy on the URL structure and their shortcuts (redirects) are causing them to get incorrect data. Using the wrong data is NOT a good thing in this case.


For example, if my actual slug is http://ift.tt/1uPyxOi



  • example.com/010HHHH redirects to http://ift.tt/1uPyxOi (Good)

  • example.com/010 could redirect to any item that starts with 010 such as http://ift.tt/1yVzLy0 (Not Good)


The preferred behavior is to simply get a 404 error for any post that is not exact for any posts that have a slug of /esm.


I have successfully solved the issue by removing the canonical filter. However, I would like the "normal" canonical behavior for any other slugs.



remove_filter('template_redirect', 'redirect_canonical');




Aucun commentaire:

Enregistrer un commentaire