Mod-Rewrite loading files behind the DocumentRoot

Question :

Mod-Rewrite loading files behind the DocumentRoot,

Answer :

I’m using .htaccess and mod_rewrite to point to files that reside behind the DocumentRoot. My folder structure looks like this:

home/      webroot/      other_files/  

I have a .htaccess file in webroot with the following content:

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

If I try to access  I receive the following error:

The requested URL /home/other_files/file.html was not found on this server.

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

Read More  Effective Ways to Introduce Agile into the Workplace?

,

I believe you need to add a section with

    (options)    

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:

Alias /doc/ "/usr/share/doc/"        Options Indexes MultiViews FollowSymLinks      AllowOverride None      Order deny,allow      Deny from all      Allow from 127.0.0.0/255.0.0.0 ::1/128    

You could then rewrite a URL to go to /doc/ and the server would know where to get the files from.

That’s the answer Mod-Rewrite loading files behind the DocumentRoot, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Read More  What does the [Flags] Enum Attribute mean in C#?

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you