[wp-hackers] Rewrite rule for pages from old site

Mika A Epstein ipstenu at ipstenu.org
Fri Jun 22 13:13:53 UTC 2012


Why not just do it in .htaccess directly?

RewriteRule ^sermons/([0-9]{4})([0-9]{2})([0-9]{2}).php?$ /sermon/$1/$2/$3?post_type=sermon [L,R=301]

(Caveat - Elf is still on that first cuppa)

Though why do you need the extra post_type on the end? The new CPT URLs should be /cpt/title/ normally, you don't generally push YMD in there (I know you can, but the guy who wrote the plugin for it dropped support because it was somewhat a bad idea).

----
Mika A Epstein (aka Ipstenu)
http://ipstenu.org | http://halfelf.org

On 22 Jun 2012, at 8:03:59AM, Brenda Egeland wrote:

> I am converting a non-WP site to WP. There are hundreds of files in the form:sermons/sermon20120325.php
> 
> These can be found on the new site at /sermon/2012/03/25?post_type=sermon 
> 
> Sermon is a custom post type. I've tried add this to my functions.php for a custom rewrite rule:
> 
> add_action('init', 'find_old_sermons');
> function find_old_sermons() {
>  add_rewrite_tag("%sermons%", '([^/]*)'); 
>  add_rewrite_rule(
>    '^/sermons/sermon([0-9]{4})([0-9]{2})([0-9]{2})\.php?',
>    '$matches[1]/$matches[2]/$matches[3]?post_type=sermon',
>    'top'
>  );
> }
> 
> But I keep getting a sorry...not found. I've tried resaving the permalinks in the Settings panel, and still no luck.
> 
> Thanks for your help.
> 
> Brenda Egeland
> Red Letter Design
> www.RedLetterDesign.net
> 301-260-7545
> 
> 
> 
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list