.htaccess Rewrite directory/file to new directory/file
<p>I'm trying to rewrite a directory and filename at the same time using .htaccess, but for some reason I can't find anything about such a case on the net. Tried googling what not, but there is simply not an example for this.</p>

<p>When I access a php file in the following directory:</p>

<p>website.com/somedir/somefile.php</p>

<p>I want to open a file that is contained at:</p>

<p>website.com/dirone/dirtwo/dirthree/dirfour/anotherfile.php</p>

<p>Tried simply 301 redirecting the directory </p>

<p>website.com/somedir/</p>

<p>to </p>

<p>website.com/dirone/dirtwo/dirthree/dirfour/</p>

<p>with</p>

<pre><code>Redirect 301 http://website.com/somedir/ http://website.com/dirone/dirtwo/dirthree/dirfour/
</code></pre>

<p>But that would only work if the file name was the same. However in my case the filename changes from somefile.php to anotherfile.php as well.</p>

<p>Also tried something like:</p>

<pre><code>RewriteRule ^somedir/somefile\.php website.com/dirone/dirtwo/dirthree/dirfour/anotherfile.php [L,QSA,NC]
</code></pre>

<p>But it did not work.</p>

<p>Any help would gladly be appreciated.</p>