I'm working on a WP multisite theme that will be deployed across a network of sites. I'm trying to get mysite.com/profile to bring the user to a frontend profile template I'm building in my theme directory called profile.php.
Currently, I'm using this:
add_action('parse_request', 'profile_url_handler');
function profile_url_handler() {
if( isset($_GET['profile']) ) {
include('profile.php');
exit();
}
}
The problem is, that leaves a ? in the URL which I'd dearly like to get rid of. I've tried using wp_rewrite to add a rewrite rule, but it won't let me get to any file except for index.php.
add_action('init', 'profile_urls');
function profile_urls() {
$themedir = get_bloginfo('stylesheet_directory');
$profile = $themedir . '/profile.php';
$new_rules = array( 'profile/?$' => $profile );
$wp_rewrite->rules = array_unshift($new_rules, $wp_rewrite->rules); // also tried $wp_rewrite->rules = $new_rules + $wp_rewrite->rules
}
Any ideas on how to make this work?