Opened 17 years ago
Closed 17 years ago
#8039 closed defect (bug) (fixed)
WP2.7 Not Respecting Custom Rewrite Rule
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | 2.7 | Priority: | normal |
| Severity: | normal | Version: | 2.7 |
| Component: | Permalinks | Keywords: | rewrite, rules, htaccess |
| Focuses: | Cc: |
Description
In WP2.7 Beta 1, apparently the custom rewrite rule is not respected.
I have added in a custom rewrite rule to WP_Rewrite. This rewrite rule is exactly the same as in WordPress 2.6 and it is at the top of the "rules" array.
[([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/email/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&email=1
When I go to http://yoursite.com/wordpress/2008/10/11/asdsadasd/email/, it will redirect me to http://yoursite.com/wordpress/2008/10/11/asdsadasd/ for no reason.
"email" is already been added to the public_query_vars
add_filter('query_vars', 'email_variables');
function email_variables($public_query_vars) {
$public_query_vars[] = 'email';
return $public_query_vars;
}
I have also placed a template redirect to take care if email=1
add_action('template_redirect', 'wp_email');
function wp_email() {
if(intval(get_query_var('email')) == 1) {
include(WP_PLUGIN_DIR.'/wp-email/email-standalone.php');
exit;
}
}
In WP2.6, the exact same code works fine, but I have no idea why in WP2.7, it does not work.
Change History (3)
#2
@
17 years ago
Yeap, I did flushed. I digged more into the problem and it seems that in WP2.7 the canonical redirect is more strict than WP2.6.
The redirect is caused by the canonical redirect. If I comment off the canonical redirect in canonical.php, it works fine.
add_action('template_redirect', 'redirect_canonical');
My wild guess would be that the canonical redirect come first before the rewrite rules. Correct me if I am not wrong.
Probably a stupid question, but you flushed the rewrite rules, correct?