<p>I'm using <code>.htaccess</code> and <code>mod_rewrite</code> to point to files that reside behind the DocumentRoot. My folder structure looks like this:</p>

<pre><code>home/
    webroot/
    other_files/
</code></pre>

<p>I have a <code>.htaccess</code> file in webroot with the following content:</p>

<pre>
RewriteEngine on
RewriteRule ^(.*)$ /home/other_files/$1
</pre>

<p>If I try to access <a href="http://example.com/file.html" rel="noreferrer">http://example.com/file.html</a> I receive the following error:  </p>

<blockquote>
  <p>The requested URL /home/other_files/file.html was not found on this server.  </p>
</blockquote>

<p>Is it even possible to load files that are behind the DocumentRoot? If so, can someone point me in the right direction?</p>

[{'answer_id': 8454, 'author': 'Ryan Ahearn', 'author_id': 75, 'author_profile': 'https://Stackoverflow.com/users/75', 'pm_score': 5, 'selected': True, 'text': '<p>I believe you need to add a section with </p>\n\n<pre><code>&lt;Directory "/home/other_files"&gt;\n  (options)\n&lt;/Directory&gt;\n</code></pre>\n\n<p>to your server configuration before apache will be able to serve anything from it.  For an example, my DocumentRoot is /var/www but there is this section in the default available site:</p>\n\n<pre><code>Alias /doc/ "/usr/share/doc/"\n&lt;Directory "/usr/share/doc/"&gt;\n    Options Indexes MultiViews FollowSymLinks\n    AllowOverride None\n    Order deny,allow\n    Deny from all\n    Allow from 127.0.0.0/255.0.0.0 ::1/128\n&lt;/Directory&gt;\n</code></pre>\n\n<p>You could then rewrite a URL to go to /doc/ and the server would know where to get the files from.</p>\n'}, {'answer_id': 9242, 'author': 'akdom', 'author_id': 145, 'author_profile': 'https://Stackoverflow.com/users/145', 'pm_score': 1, 'selected': False, 'text': '<p>Just so you know why that rule doesn\'t work:</p>\n<p>The reason that it isn\'t able to rewrite to <code>/home/other_files/file.html</code> is that mod_rewrite is parsing the path as <code>/home/webroot/home/other_files/file.html</code> since from mod_rewrite\'s point of view the preceding slash is equivalent to your document root of <code>/home/webroot</code>.</p>\n<p><a href="https://stackoverflow.com/questions/8441/mod-rewrite-loading-files-behind-the-documentroot#8454">Ryan Ahearn\'s suggestion</a> is a decent one, and is likely the route you want to go.</p>\n'}, {'answer_id': 32534645, 'author': 'Joe C', 'author_id': 883354, 'author_profile': 'https://Stackoverflow.com/users/883354', 'pm_score': 1, 'selected': False, 'text': "<p>The credit goes to Ryan Aheam, but I'm going to spell it out. I'm a beginner and even with Ryan's answer I had to experiment with a few things to get the syntax right.</p>\n<p>I wanted my <code>DocumentRoot</code> to be my <code>cakephp</code> directory. But then I had a Mantis Bug tracker that was just regular PHP and so not in the <code>cakephp</code> directory.  The the files below I have the following working.</p>\n<p><code>http://www.example.com</code> : served by  <code>/var/www/cakephp</code></p>\n<p><code>http://www.example.com/mantisbt</code> : served by <code>/var/www/html/mantisbt</code></p>\n<p>File <code>/etc/httpd/conf/httpd.conf</code></p>\n<pre><code>Alias /mantisbt/ &quot;/var/www/html/mantisbt/&quot;                                                                          \n&lt;Directory &quot;/var/www/html/&quot;&gt;                                                                                        \n    AllowOverride All                                                                                               \n&lt;/Directory&gt;                                                                                                        \n                                                                                                                    \n&lt;VirtualHost *:80&gt;                                                                                                  \n    ServerAdmin me@my_email.com                                                                             \n    DocumentRoot /var/www/cakephp                                                                                   \n    ServerName my_website.com                                                                                      \n    &lt;Directory /var/www/cakephp/&gt;                                                                                   \n        AllowOverride All                                                                                           \n    &lt;/Directory&gt;                                                                                                    \n&lt;/VirtualHost&gt;\n</code></pre>\n<p>File <code>/var/www/cakephp/.htaccess</code></p>\n<pre><code>&lt;IfModule mod_rewrite.c&gt;\n    RewriteEngine on\n    RewriteRule    ^mantisbt/?$   /mantisbt/  [NC,L]\n    RewriteRule    ^$    webroot/    [L]\n    RewriteRule    (.*) webroot/$1    [L]\n&lt;/IfModule&gt;\n</code></pre>\n"}]
['https://Stackoverflow.com/questions/8441', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/57/']