views:

131

answers:

3

As a follow up to an earlier question that attracted a whole zero answers, I'm wondering about the possibilities of allowing a web server (apache) to write to its own document root (Linux), in order to dynamically create meta-redirect files.

Of course, this sounds incredibly dangerous, and I'm wary of going the whole hog and granting the web-server user full write-access to its own docroot. Is there a more appropriate way of achieving this?

+2  A: 

What's usually done is to allow writes only to subdirectories, hopefully located in a noexec mounted partition.

That said, it seems to me that you should just create a set of RewriteMap directives to do your dynamic redirection, there's no need to write files in the document root to accomplish that.

I answered similarly in the other question, just for completeness.

Vinko Vrsalovic
+1  A: 

This is incredibly dangerous if you are trying to achieve what your previous question was getting at.

If you are going to go this route, you'll want a ton of testing to prevent people from forcing webserver instructions into htaccess files.

epochwolf
+3  A: 

Use mod-rewrite, mapping to a program that you write to do the rewrites based on database records or some other mechanism.

Instructions here:

http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

Look for: "External Rewriting Program" on the page

Edit (from Vinko in the comments, 2.2 docs)

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritemap

Lou Franco
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritemap
Vinko Vrsalovic