By 'existing page' do you mean a WordPress page? My experience with rewrites is routing everything to index.php with whatever extra query vars you need, I think attempting to route it to edit
is one of your issues, not entirely clear on your intent there.
Go download Monkeyman Rewrite Analyzer if you don't already have it, it's a great tool for testing these things out.
I tested out the following rule to verify it works. All requests to /edit/*
get routed toload a page named 'edit', get_query_var('e')
returns the correct value for e
in my template.
Note I didn't flush the rules here, I usually just visit the Settings > Permalinks
page and click save to flush whenever I change them.
<?php
add_action( 'init', 'my_rewrites_init' );
function my_rewrites_init(){
add_rewrite_rule(
'edit/([^/]+)/?',
'index.php?pagename=edit&e=$matches[1]',
'top' );
}
add_filter( 'query_vars', 'my_query_vars' );
function my_query_vars( $query_vars ){
$query_vars[] = 'e';
return $query_vars;
}