You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Sean DeNigris <se...@clipperadams.com> on 2009/02/28 04:05:27 UTC

Re: [users@httpd] Can you go outside the .htaccess directory with Rewrite Rule?

> On Fri, Feb 27, 2009 at 4:27 PM, Sean DeNigris  
> <se...@clipperadams.com> wrote:
> > If I put a .htaccess file in my webroot with the following rule:
> > RewriteRule ^(.*)$ /cgi-bin/scriptname.cgi?action=$1
> >
> > Can I specify a script file outside the directory with  
> the .htaccess file in
> > it (i.e. outside the webroot)?
>
> Yes, the 2nd argument to RewriteRule is actually a filesystem path and
> not a URL -- rewrite helps you out sometimes when you use the latter.
Thanks for the help!!
Ok I'm encouraged that it's possible, but my example resolves to / 
~user/public_html/cgi-bin/, not /~user/cgi-bin/, which is what I want,  
and what it sounds like you're saying it should do, so how do I get  
this filesystem behavior?
> With the default conf, directory trees are explicitly allowed to be
> served via "order" and "allow", so whatever you rewrite to will to
> have a Directory stanza that allows access.
I'm not sure what this means.

Sean

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Can you go outside the .htaccess directory with Rewrite Rule?

Posted by Krist van Besien <kr...@gmail.com>.
On Sat, Feb 28, 2009 at 4:05 AM, Sean DeNigris <se...@clipperadams.com> wrote:

> Thanks for the help!!
> Ok I'm encouraged that it's possible, but my example resolves to
> /~user/public_html/cgi-bin/, not /~user/cgi-bin/, which is what I want, and
> what it sounds like you're saying it should do, so how do I get this
> filesystem behavior?

You need to restart request processing after the rewrite. For this you
add the PT flag. To quote the manual:
"The target (or substitution string) in a RewriteRule is assumed to be
a file path, by default. The use of the [PT] flag causes it to be
treated as a URI instead. That is to say, the use of the [PT] flag
causes the result of the RewriteRule to be passed back through URL
mapping, so that location-based mappings, such as Alias, for example,
might have a chance to take effect. "

So your rule needs to look like this:

RewriteRule ^(.*)$ /cgi-bin/scriptname.cgi?action=$1 [PT]


Krist

-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org