title: .htaccess 301 redirect page with no extension to a PHP page
body: <p>I'm having a problem getting an old WordPress site page to redirect to the new basic PHP site page.</p>
  
  <p>Example: The old WordPress page with no extension is at <code>http://example.com/levelone/leveltwo/pagename</code></p>
  
  <p>The new page is at <code>http://example.com/directory/pagename.php</code>.</p>
  
  <p>Here are several things I've tried:</p>
  
  <pre><code>redirect 301  /levelone/leveltwo/pagename http://example.com/directory/pagename.php
  </code></pre>
  
  <p>This did not work at all</p>
  
  <p>Then I tried redirecting the directories first, then the page, like so:</p>
  
  <pre><code>RedirectMatch 301 ^/levelone/leveltwo/ http://example.com/directory/
  redirect 301  /pagename http://example.com/pagename.php
  </code></pre>
  
  <p>This almost worked, but gave me the right URL but without the PHP extension.</p>
  
  <p>I can't just redirect an old directory to a new one because there are actually many. The example is just one. The trouble seems to be going from a non-extension page to a page with the <code>.php</code> extension.</p>
  
  <p>Here's another thing I tried:</p>
  
  <pre><code>RedirectMatch 301 ^/levelone/leveltwo/(.*)$ /directory/$1.php
  redirect 301  /pagename http://example.com/pagename.php
  </code></pre>
  
  <p>This gave me <code>http://example.com/directory/pagename/.php</code>.</p>
  
  <p><em><strong>Solved: I got it to work with the following:</em></strong></p>
  
  <pre><code>Redirect 301 /levelone/leveltwo/pagename/ http://example.com/directory/pagename.php
  </code></pre>
  
  <p>The problem seemed to be with the missing forward-slash after the old page name. </p>