Rewrite Rules – Some Don’t Work?
-
So I’m using mod_rewrite for a couple of plugins (Now Reading, and one I made myself), and bunched all of my custom rewrite rules together (so yes, it’s messy – please excuse me):
function nr_mod_rewrite( $rules ) { global $wp_rewrite; $rules['^gallery/([^/]+)/([^/]+)/?$'] = 'index.php?fg_gallery=true&fg_set=' . $wp_rewrite->preg_index(1) . '&fg_single=' . $wp_rewrite->preg_index(2); $rules['^gallery/([^/]+)/?$'] = 'index.php?fg_gallery=true&fg_moreset=' . $wp_rewrite->preg_index(1); $rules['^gallery/?$'] = 'index.php?fg_gallery=true'; $rules['^library/([0-9]+)/?$'] = 'index.php?now_reading_id=' . $wp_rewrite->preg_index(1); $rules['^library/tag/([^/]+)/?$'] = 'index.php?now_reading_tag=' . $wp_rewrite->preg_index(1); $rules['^library/search/?$'] = 'index.php?now_reading_search=true'; $rules['^library/([^/]+)/([^/]+)/?$'] = 'index.php?now_reading_author=' . $wp_rewrite->preg_index(1) . '&now_reading_title=' . $wp_rewrite->preg_index(2); $rules['^library/([^/]+)/?$'] = 'index.php?now_reading_author=' . $wp_rewrite->preg_index(1); $rules['^library/?$'] = 'index.php?now_reading_library=true'; return $rules; } add_filter('rewrite_rules_array', 'nr_mod_rewrite');
My problem is thus:
Some of the rules work fine and dandy. The following rewrite rules don’t work at all, the variables don’t appear in $wp->query_vars or anything (yes, I registered them – see below).
$rules['^gallery/([^/]+)/?$'] = 'index.php?fg_gallery=true&fg_moreset=' . $wp_rewrite->preg_index(1); $rules['^gallery/?$'] = 'index.php?fg_gallery=true'; $rules['^library/search/?$'] = 'index.php?now_reading_search=true'; $rules['^library/([^/]+)/?$'] = 'index.php?now_reading_author=' . $wp_rewrite->preg_index(1); $rules['^library/?$'] = 'index.php?now_reading_library=true';
function nr_query_vars( $vars ) { $vars[] = 'now_reading_library'; $vars[] = 'now_reading_id'; $vars[] = 'now_reading_tag'; $vars[] = 'now_reading_search'; $vars[] = 'now_reading_title'; $vars[] = 'now_reading_author'; $vars[] = 'fg_gallery'; $vars[] = 'fg_single'; $vars[] = 'fg_moreset'; $vars[] = 'fg_set'; return $vars; } add_filter('query_vars', 'nr_query_vars');
It’s as though the rules clash somehow, they all give me 404s unless I’m viewing the most specific pages (ones with author and title, or set and photograph). Can anyone enlighten me on how to get it working?
Thanks.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Rewrite Rules – Some Don’t Work?’ is closed to new replies.