[wp-hackers] Rewrite rule for pages from old site
otto at ottodestruct.com
Fri Jun 22 13:23:22 UTC 2012
On Fri, Jun 22, 2012 at 8:03 AM, Brenda Egeland
<brenda at redletterdesign.net> wrote:
> Sermon is a custom post type. I've tried add this to my functions.php for a custom rewrite rule:
> But I keep getting a sorry...not found. I've tried resaving the permalinks in the Settings panel, and still no luck.
That isn't how rewrite rules work.
You're trying to rewrite the old .php based URL into the new "pretty"
url, but what a rewrite rule in WP does is to convert a "pretty" URL
into a "default" URL. Default is that thing with ?p=123&year=2012 and
In other words, you can do what you want, but the second part of the
rewrite rule needs to be "non-pretty".
Or something like that. Didn't test it specifically, might be wrong.
But that won't redirect the old URL to the new one, that will just
make the old URL work and show the proper content.
If you're wanting to actually REDIRECT from the old format to the new
one, then you're doing it wrong. add_rewrite_rule can't do that
directly. (Well, it *can*, it's just a bit pointless to do it that
way). If you want to redirect from the old to the new, then putting a
RewriteRule directly into the .htaccess (as Mika suggested previously)
is the simpler and easier way.
More information about the wp-hackers