[wp-hackers] Bug or feature: Wordpress default rewrite rules cannot be overridden?

Bjorn Wijers burobjorn at gmail.com
Sun Dec 6 14:04:59 UTC 2009


Austin,

Thank you very much for your quick reply!.

I'm not quite there yet. Since using this gives me a 404 instead of the
page it should redirect to. I presume my rule does not match correctly
when using permalinks? Or am I missing something else?

This is the rule I use:

$docs_rule3 = array(
'this-is-a-page/this-is-my-public-q-var/([a-zA-Z0-9]{1,})/?$' =>
'index.php?pagename=this-is-a-page&my-extra-var=this-is-my-public-q-var&this-is-a-var=$matches[1]'
);

To match this:

http://site.dev/this-is-a-page/this-is-my-public-query-var/this-is-a-random-string/

or without permalinks

http://site.dev/?pagename=this-is-a-page&my-extra-var=this-is-my-public-query-var&this-is-a-var=this-is-a-random-string

Both should redirect to the page. In this case with the name
this-is-a-page.

Any help much appreciated!

grtz
BjornW




Austin Matzko wrote:
> On Sun, Dec 6, 2009 at 6:58 AM, Bjorn Wijers <burobjorn at gmail.com> wrote:
>> However when this-is-a-random == an-existing-post-name it does not work
>> instead it redirects to the single post template. BUT only when
>> permalinks are switched on! If permalinks are off it still works.
> 
> I believe what you're seeing is a feature called "canonical redirect,"
> which attempts to guess the correct destination for non-matching URLs.
> 
>> Basically what I want is
>>
>> First check my rules for blog posts and use these if they match
>> otherwise continue with the default rules/behaviour, which it does for
>> all strings not similar to an existing postname.
> 
> You should be able to disable canonical redirect like so:
> 
> remove_action('template_redirect', 'redirect_canonical');
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
> 


-- 

met vriendelijke groet,
Bjorn Wijers

* b u r o b j o r n .nl *
digitaal vakmanschap | digital craftsmanship

Concordiastraat 68-126
3551 EM Utrecht
The Netherlands

phone: +31 6 49 74 78 70
http://www.burobjorn.nl


More information about the wp-hackers mailing list