URL parameter in WordPress mod_rewrite URL to fake subpath

159 views Asked by At

I know there are other questions, but none of them have answers that work for this.

I have a page on my WordPress site with the slug profile, and I have it set up to take a ?username= URL parameter. However, this is ugly, and I would like to be able to go to http://website.com/profile/andy instead of http://website.com/profile/?username=andy. Is there something I can put in my functions.php to do this? I currently have:

add_filter('query_vars', 'parameter_queryvars');
function parameter_queryvars($qvars) {
    $qvars[] = 'id';
    $qvars[] = 'username';
    $qvars[] = 'profileredirect';
    $qvars[] = 'reason';
    return $qvars;
}

This prevents WordPress from stripping id, username, profileredirect, or reason from the URL. Once rewritten, I would still need to be able to use http://website.com/profile/?profileredirect=true&reason=andy. I could live without id, it's not referenced anywhere and is only there because I haven't removed it.

Thanks!

0

There are 0 answers