[wp-hackers] WP_Rewrite without query var
Chris McCoy
chris at lod.com
Sat Aug 25 21:08:23 UTC 2012
Im trying to rewrite a long file url to a shorter one.
Basically I have zips in a plugin folder I want to rewrite to
/downloads/filename.zip instead of
/wp-content/plugins/plugin-name/zips/filename.zip
Cant figure what im doing wrong.
Here is what I have
define('ZT_URL', plugins_url('zips/' , __FILE__));
add_action('generate_rewrite_rules', 'cmm_add_rewrite_rules');
function cmm_add_rewrite_rules( $wp_rewrite ) {
$new_rules = array(
"^downloads/(.+)\.zip$" => ZT_URL .
$wp_rewrite->preg_index(1)
);
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
add_action('init','cmm_flush_rules');
function cmm_flush_rules(){
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
Any input is greatful.
More information about the wp-hackers
mailing list