snipt

Ctrl+h for KB shortcuts

Text only

mod_rewrite child folder inherit parent rewrite rules

You need to add the following line into each .htaccess in subfolders if you want to have rewrite rules from parent .htaccess to be executed as well:

RewriteOptions inherit

This forces the current configuration to inherit the configuration of the parent. In per-virtual-server context, this means that the maps, conditions and rules of the main server are inherited. In per-directory context this means that conditions and rules of the parent directory's .htaccess configuration are inherited.

Rules inherited from the parent scope are applied after rules specified in the child scope.

http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriteoptions

from
http://stackoverflow.com/questions/7443902/get-htaccess-from-root-directory-to-apply-on-all-directories
https://snipt.net/embed/c2b8248ca8d5b84a35a29e3433cc325e/
/raw/c2b8248ca8d5b84a35a29e3433cc325e/
c2b8248ca8d5b84a35a29e3433cc325e
text
Text only
12
2019-08-17T23:43:56
True
False
False
/api/public/snipt/50071/
mod_rewrite-child-folder-inherit-parent-rewrite-rules
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1"> 1</a> <a href="#L-2"> 2</a> <a href="#L-3"> 3</a> <a href="#L-4"> 4</a> <a href="#L-5"> 5</a> <a href="#L-6"> 6</a> <a href="#L-7"> 7</a> <a href="#L-8"> 8</a> <a href="#L-9"> 9</a> <a href="#L-10">10</a> <a href="#L-11">11</a> <a href="#L-12">12</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>You need to add the following line into each .htaccess in subfolders if you want to have rewrite rules from parent .htaccess to be executed as well: </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>RewriteOptions inherit </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>This forces the current configuration to inherit the configuration of the parent. In per-virtual-server context, this means that the maps, conditions and rules of the main server are inherited. In per-directory context this means that conditions and rules of the parent directory&#39;s .htaccess configuration are inherited. </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a>Rules inherited from the parent scope are applied after rules specified in the child scope. </span><span id="L-8"><a name="L-8"></a> </span><span id="L-9"><a name="L-9"></a>http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriteoptions </span><span id="L-10"><a name="L-10"></a> </span><span id="L-11"><a name="L-11"></a>from </span><span id="L-12"><a name="L-12"></a>http://stackoverflow.com/questions/7443902/get-htaccess-from-root-directory-to-apply-on-all-directories </span></pre></div> </td></tr></table>