php - Rewrite rule doesn't use matches -


a client's wordpress based web site has employee pages urls this:
/bio/john-doe/
/bio/nim-rod/
etc...

but on printed brochures , business cards want urls like:
/nim.rod
, have site show /bio/nim-rod/ page.

according client used work. there php file in plugins folder has looks rewrite rules capability (see below), can't work.

i researched problem , found this post on wordpress' support site suggested fix doesn't work:

trying troubleshoot issue added test rules code, example rule redirect /any.name /bio/nim-rod/ page,

$newrules['([a-za-z]+)\.([a-za-z]+)'] = 'index.php?pagename=nim-rod';  

so rewriting module finding custom rule , showing /bio/nim-rod/ page, existing rule using regex matches ends showing site's 404 page. there seems wrong substituting matched values regex pattern, can't find wrong syntax , don't know how troubleshoot further. existing pattern looks should work, shouldn't it?

around 6 months ago server had hardware problems , our former wordpress/php expert rebuilt site , upgraded version 3.3.1. don't know old version was, possible new version broke feature.

are there troubleshooting tips can point me to?
there tools out there can use debug or inspect how regex working?

<?php /**  * @package custom_redirector  * @version 1.0.0  */ /* plugin name: custom redirector plugin uri: http://wordpress.org/# description:  version: 1.0.0 author uri: http://ma.tt/ */  add_filter('rewrite_rules_array','wp_insertmyrewriterules'); add_filter('query_vars','wp_insertmyrewritequeryvars'); add_filter('init','flushrules');  // remember flush_rules() when adding rules function flushrules(){     global $wp_rewrite;     $wp_rewrite->flush_rules(); }  // adding new rule function wp_insertmyrewriterules($rules) {     $newrules = array();     $newrules['([a-za-z]+)\.([a-za-z]+)'] = 'index.php?pagename=$matches[1]-$matches[2]';     return $newrules + $rules; }  // adding id var wp recognizes function wp_insertmyrewritequeryvars($vars) {     array_push($vars, 'id');     return $vars; } ?> 

try this;

([a-za-z]+)(?:\.|-)([a-za-z]+) 

by way, string match 2 things index.php?pagename=nim-rod:

index.php?pagename=nim-rod

if don't want that, use;

([a-za-z]+)-([a-za-z]+) 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -