Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

almightymax on "cant understand how to rewrite url"

$
0
0

Hey guys, I had read a lot of articles, guides & tips and still cant understand how to rewrite rule.
Here is what i got:
my url:

http://localhost/wordpress/?navopt=main

my code in functions.php:

/*
 * Add rewrite tags
 */
function add_new_rewrite_tags() {
    add_rewrite_tag(
            '%index%',
            '([^/]*)' ) ;
}
add_action( 'register_special_query_vars', 'add_new_rewrite_tags' ); /*hooked to a previous function which gets vars from the url.*/

/*
 * Rewriting rules
 */
function query_rewrite_new_rules() {
    add_rewrite_rule(
            '^/([^/]*)',
            '?navopt=$matches[1]',
            'top' );
}
add_action( 'add_new_rewrite_tags', 'query_rewrite_new_rules');

Viewing all articles
Browse latest Browse all 8245

Trending Articles