Title: Code for better match
Last modified: August 30, 2016

---

# Code for better match

 *  [Shivanand Sharma](https://wordpress.org/support/users/varun21/)
 * (@varun21)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/code-for-better-match/)
 * Currently the requested url is matched against the entire permalink. I think 
   it would be better instead to match it to the slug of the existing posts.
 * `function wbz404_rankPermalinks` in functions.php could use the following code
   for a better match.
 *     ```
       $slug = explode('/',$urlParts['path']);
       $slug = array_pop($slug);
       $levscore = levenshtein($url, $slug,1,1,1);
       ```
   
 * [https://wordpress.org/plugins/404-redirected/](https://wordpress.org/plugins/404-redirected/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [Shivanand Sharma](https://wordpress.org/support/users/varun21/)
 * (@varun21)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/code-for-better-match/#post-6777800)
 * Aletrnatively in includes/functions.php, the following can be inserted after 
   line 205:
 *     ```
       $urlParts['path'] = basename($urlParts['path']);
       $url = basename($url);
       ```
   
 *  Plugin Contributor [Remkus de Vries](https://wordpress.org/support/users/defries/)
 * (@defries)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/code-for-better-match/#post-6777805)
 * I took over the development of this plugin a few weeks ago, I’d love for you 
   to create an issue here with matching pull request : [https://github.com/defries/404-redirected/issues](https://github.com/defries/404-redirected/issues)

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Code for better match’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/404-redirected.svg)
 * [Redirectioner](https://wordpress.org/plugins/404-redirected/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/404-redirected/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/404-redirected/)
 * [Active Topics](https://wordpress.org/support/plugin/404-redirected/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/404-redirected/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/404-redirected/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Remkus de Vries](https://wordpress.org/support/users/defries/)
 * Last activity: [9 years, 11 months ago](https://wordpress.org/support/topic/code-for-better-match/#post-6777805)
 * Status: not resolved