title: Extract ID and rewrite URL
body: <p>I moved a website to wordpress. Therefore I want to redirect the old posts to the corresponding wordpress post.</p>
  
  <p>The old url contains an id which I want to extract and map to wordpress.</p>
  
  <p>Example for the old URL:</p>
  
  <pre><code>www.mydomain.com/include.php?BLABLAcontentid=XXBLABLA' 
  </code></pre>
  
  <p>which I want to map to the new URL:</p>
  
  <pre><code>'www.mydomain.com/?p=XX'
  </code></pre>
  
  <p>where XX is a number containing 0-9</p>
  
  <p>I'm trying to extend the wordpress rewrite by the following rule</p>
  
  <pre><code>RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
  
  RewriteRule ^include(.*)$ index%1 [PT]
  RewriteRule ^include(.*)$ index$1 [L,QSA]
  
  RewriteCond %{QUERY_STRING} (.*)contentid=([0-9]+)
  RewriteRule .* /?p=%2 [R,L]
  </code></pre>
  
  <p>If I call 'www.mydomain.com/index.php?BLABLAcontentid=XXBLABLA' it works correctly, therefore I tried to replace include by index, but this doesn't seem to work. Any hints on how I can proceed here?</p>
  
  <p>Thanks in advance and regards,</p>
  
  <p>Tim</p>