Gentoo Archives: gentoo-user

From: Hilco Wijbenga <hilco.wijbenga@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] [Apache HTTPD] Why doesn't my RewriteRule fire?
Date: Mon, 22 Aug 2011 22:14:37
Message-Id: CAE1pOi0OrMm5NJ6zDtK75dKZ2VJYC_G73tS+cORFKARjmYLuFQ@mail.gmail.com
In Reply to: Re: [gentoo-user] [Apache HTTPD] Why doesn't my RewriteRule fire? by Paul Hartman
1 On 22 August 2011 14:31, Paul Hartman <paul.hartman+gentoo@×××××.com> wrote:
2 > On Mon, Aug 22, 2011 at 4:07 PM, Hilco Wijbenga
3 > <hilco.wijbenga@×××××.com> wrote:
4 >>  RewriteRule ^/website$    http://localhost/website/ [T]
5 >>  ProxyPassMatch    ^/website/(.*)$
6 >> http://localhost:8000/website/$1
7 >> </VirtualHost>
8 >>
9 >> The ProxyPassMatch fires but (AFAICT) the RewriteRule does not. I.e.
10 >> http://localhost/website (no slash) ==> 404 (in fact, it's trying to
11 >> serve /var/www/localhost/htdocs/website) but http://localhost/website
12 >> (with slash) ==> works.
13 >
14 > Disclaimer: I am not an Apache guru :)
15
16 Well, you know more than I do. :-)
17
18 > You have [T] as third parameter to RewriteRule, which is used to
19 > specify a MIME type,  but you're not specifying anything. Maybe that
20 > invalidates the rule. Try removing it.
21 >
22 > You can also specify multiple RewriteRules which are processed in
23 > sequence, if trailing slash works maybe you need to first add a rule
24 > convert URL with no slash to URL with slash:
25 >
26 > RewriteRule ^/website$ /website/ [R]
27
28 I used to have [P] and then tried [PT] but neither worked. Then for
29 some unknown reason I deleted the P and left [T] when I sent the
30 email.
31
32 The problem turns out to be that you must put the Rewrite*
33 configuration stuff in the virtual host, not outside. Then it works.
34 It's documented but I had glossed over it.