[wp-hackers] Update Plugin Rewrite Rules
Mr.Brown
mrbrog at gmail.com
Thu Feb 2 16:40:59 GMT 2006
David House wrote:
> I assume you're adding them directly to the .htaccess file. Don't. Use
> $wp_rewrite. http://codex.wordpress.org/Function_Reference/WP_Rewrite
> and the second example on that page should be able to help you.
I'm sorry if I come back on this topic, but I tried to do as you suggested to me
but I wasn' t able to solve. I want to do this: I create a page
template like this
<?php
/*
Template Name: Pics Template
*/
// and so on...
?>
then I create a Page, with this template an with the slug 'pics'
Now instead of using "mysite.com/pics/?file=mypic"
I want to call this page in this way: "mysite.com/pics/mypic/"
and in the template I want to have the $_GET['file'] with value "mypic".
I tried to add rewrite rules as you suggested to me, but while the url
"mysite.com/pics/" displays the new page, the url
"mysite.com/pics/mypic/" redirects me to the home page.
The original rule was
RewriteRule ^pics/([^/]+)/$ /pics/?mypic=$1 [QSA,L]
I added the rules by a plugin (I'm not sure I understood the mechanism):
<?php
function RTS_pics_rewrite($rewrite) {
global $wp_rewrite;
$keytag_token = '%pics%';
$wp_rewrite->add_rewrite_tag($keytag_token, '(.+)', album=');
$keywords_structure = $wp_rewrite->root . "pics/$keytag_token";
$keywords_rewrite = $wp_rewrite->generate_rewrite_rules($keywords_structure);
return ( $rewrite + $keywords_rewrite );
}
add_filter ('rewrite_rules_array', 'RTS_pics_rewrite');
?>
I tried also with
add_filter ('page_rewrite_rules', 'RTS_pics_rewrite'); and
add_filter ('root_rewrite_rules', 'RTS_pics_rewrite');
Any ideas?
Thanks in advance
--
Mr.Brown
More information about the wp-hackers
mailing list