Nicely done :)

I'm not sure where, but a caveat of 'Put your rules ABOVE WPs' might not be a bad idea. That way you only have to run through the WP processing once and put a little less load on your box.

Cookies and cake for David!

Quoting David Miles <[email protected]>:

Hey Otto,
Thank you very much!  I'll update the document to reflect that.  Like I
mentioned before, it's odd how obscure information on adding .htaccess
content indirectly is and that's why I took a few hours to write that.

I really appreciate your help and everything else you've contributed to the
WordPress community.  I've come across at least a handful of your tutorials
that have been priceless in helping me learn how to develop themes and
plugins *correctly* for WordPress.  That takes a lot of time to do that and
I appreciate it.


On Wed, Aug 31, 2011 at 12:09 PM, Otto <[email protected]> wrote:

BTW, you did get very close to this there at the end. What you missed
was that the add_rewrite_rule function (not the class function, but
the normal one), makes the resulting call to add_rule in the class.
This then does the index.php based determination, and adds the rule to
the $non_wp_rules there.

No need for an action on generate_rewrite_rules. That's the hard way
to do it. Put your action on init, then just call the add_rewrite_rule
function normally.

-Otto



On Wed, Aug 31, 2011 at 12:03 PM, Otto <[email protected]> wrote:
> You missed a rather simple trick that not many people know about. This
> will add a rule to the .htaccess file when the rules are hard flushed.
>
> add_rewrite_rule('myrule', '/newlocation');
>
> In WordPress, all "internal" rewrite rules must start with "index.php"
> for them to work properly. Any rule that doesn't start with index.php
> gets shoved out into the .htaccess file as a normal RewriteRule when
> the flush happens (basically when you visit the Settings->Permalink
> page).
>
> So you can use normal add_rewrite_rule calls to add normal .htaccess
> rules as well as the internal kind.
>
> Note: Internal rules use the $matches[1] method for referencing
> pattern matchers. This won't work in .htaccess rules, you have to use
> the $1 method for those rules.
>
> -Otto
>
>
>
> On Wed, Aug 31, 2011 at 11:33 AM, David Miles <[email protected]>
wrote:
>> Hey everyone,
>> I recently dove into trying to utilize WordPress's rewrite engine and
how to
>> add content to the .htaccess file indirectly.
>> I discovered the first part wasn't too complicated once I read over a
few
>> tutorials, but modifying/adding to the .htaccess file was a whole
different
>> story.
>> So I decided to take a few hours and write some (hopefully helpful)
>> information to help
>> others,
http://codex.wordpress.org/User:Amereservant/Editing_and_Customizing_htaccess_Indirectly
>> I'm sure there's things I've missed or perhaps some of you have more
>> advanced knowledge of the topic and can refine the information to be
more
>> useful.
>> Either way, I'd love to hear feedback on it and what you think.
>> Thanks,
>>
>> David
>> _______________________________________________
>> wp-docs mailing list
>> [email protected]
>> http://lists.automattic.com/mailman/listinfo/wp-docs
>>
>>
>
_______________________________________________
wp-docs mailing list
[email protected]
http://lists.automattic.com/mailman/listinfo/wp-docs





_______________________________________________
wp-docs mailing list
[email protected]
http://lists.automattic.com/mailman/listinfo/wp-docs

Reply via email to