FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 08-22-2011, 09:07 PM
Hilco Wijbenga
 
Default Why doesn't my RewriteRule fire?

Hi all,

I hope some Apache guru can help me out. I must be missing something
very obvious.

Assume a default Apache 2.2.17 with all modules installed and -D PROXY
-D INFO in /etc/conf.d/apache2.

My update to the default VHOST:

ForensicLog /var/log/apache2/forensic.log
ProxyRequests off
RewriteEngine on
RewriteLogLevel 9
RewriteLog /var/log/apache2/rewrite.log
<VirtualHost *:80>
ServerName localhost
ServerAdmin root@localhost
DocumentRoot "/var/www/localhost/htdocs"
<Directory "/var/www/localhost/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Directory>
RewriteRule ^/website$ http://localhost/website/ [T]
ProxyPassMatch ^/website/(.*)$
http://localhost:8000/website/$1
</VirtualHost>

The ProxyPassMatch fires but (AFAICT) the RewriteRule does not. I.e.
http://localhost/website (no slash) ==> 404 (in fact, it's trying to
serve /var/www/localhost/htdocs/website) but http://localhost/website
(with slash) ==> works.

Why does the RewriteRule not run? FYI, rewrite.log is created but
stays empty. I don't see any errors or warnings in access.log or
error.log.

Cheers,
Hilco
 
Old 08-22-2011, 09:31 PM
Paul Hartman
 
Default Why doesn't my RewriteRule fire?

On Mon, Aug 22, 2011 at 4:07 PM, Hilco Wijbenga
<hilco.wijbenga@gmail.com> wrote:
> *RewriteRule ^/website$ * *http://localhost/website/ [T]
> *ProxyPassMatch * *^/website/(.*)$
> http://localhost:8000/website/$1
> </VirtualHost>
>
> The ProxyPassMatch fires but (AFAICT) the RewriteRule does not. I.e.
> http://localhost/website (no slash) ==> 404 (in fact, it's trying to
> serve /var/www/localhost/htdocs/website) but http://localhost/website
> (with slash) ==> works.

Disclaimer: I am not an Apache guru

You have [T] as third parameter to RewriteRule, which is used to
specify a MIME type, but you're not specifying anything. Maybe that
invalidates the rule. Try removing it.

You can also specify multiple RewriteRules which are processed in
sequence, if trailing slash works maybe you need to first add a rule
convert URL with no slash to URL with slash:

RewriteRule ^/website$ /website/ [R]
 
Old 08-22-2011, 10:13 PM
Hilco Wijbenga
 
Default Why doesn't my RewriteRule fire?

On 22 August 2011 14:31, Paul Hartman <paul.hartman+gentoo@gmail.com> wrote:
> On Mon, Aug 22, 2011 at 4:07 PM, Hilco Wijbenga
> <hilco.wijbenga@gmail.com> wrote:
>> *RewriteRule ^/website$ * *http://localhost/website/ [T]
>> *ProxyPassMatch * *^/website/(.*)$
>> http://localhost:8000/website/$1
>> </VirtualHost>
>>
>> The ProxyPassMatch fires but (AFAICT) the RewriteRule does not. I.e.
>> http://localhost/website (no slash) ==> 404 (in fact, it's trying to
>> serve /var/www/localhost/htdocs/website) but http://localhost/website
>> (with slash) ==> works.
>
> Disclaimer: I am not an Apache guru

Well, you know more than I do. :-)

> You have [T] as third parameter to RewriteRule, which is used to
> specify a MIME type, *but you're not specifying anything. Maybe that
> invalidates the rule. Try removing it.
>
> You can also specify multiple RewriteRules which are processed in
> sequence, if trailing slash works maybe you need to first add a rule
> convert URL with no slash to URL with slash:
>
> RewriteRule ^/website$ /website/ [R]

I used to have [P] and then tried [PT] but neither worked. Then for
some unknown reason I deleted the P and left [T] when I sent the
email.

The problem turns out to be that you must put the Rewrite*
configuration stuff in the virtual host, not outside. Then it works.
It's documented but I had glossed over it.
 

Thread Tools




All times are GMT. The time now is 12:42 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org