title: How to change an existing Wordpress page rewrite rule?
body: <p>I've created a new page layout the data there is taken from a text file and the name of the file is passed in a parameter so for example the url looks like this:</p>
  <pre><code>http://localhost/&lt;parentpage slug&gt;/&lt;sub page slug&gt;/?mytextpage=test
  </code></pre>
  <p>my question is how, where and what should I change in the existing rewrite rules so my new urls would look like this:</p>
  <pre><code>http://localhost/&lt;parentpage slug&gt;/&lt;sub page slug&gt;/mytextpage/test/
  </code></pre>
  <p>I was able to find questions here about how to create new rewrite rules for custom pages but not on how to change the existing wordpress rules.</p>
  <p>Thanks for the help.</p>
  <p><em><strong>UPDATE</strong></em></p>
  <p>I used the following code and i was able to get to the target page but the parameter &quot;test&quot; didn't pass.</p>
  <pre><code>add_filter( 'query_vars', 'wpa543_query_vars' );
  function wpa543_query_vars( $query_vars )
  {
   $query_vars[] = 'd';
   return $query_vars;
  }
  
      add_action( 'init', 'wpa543_init' );
      function wpa543_init()
      {
       add_rewrite_rule(
          'class/([^/]+)/?',
          'index.php?page_id=5&amp;d=$matches[1]',
          'top' );
       flush_rewrite_rules();
      } 
  </code></pre>
  <p>what need to be changed in the code so it will pass the parameter?</p>
  <p>also this code gives me only a partial solution because I still don't know how to pass the <code>parent page slug</code> and the <code>sub page slug</code></p>