Hi,
I am trying to get mod_rewrite rules to work under apache 2.2 on Debian Lenny. To try to get it to work first I put the rules in /etc/apache2/mods-enabled/rewrite.load:
RewriteEngine On
RewriteRule http-poll/ http://jabberserver:5280/http-poll [P]
RewriteLog "/tmp/rewrite.log"
RewriteLogLevel 3
However I get 404 error when I use a browser to go to http://localhost/http-poll after restarting apache. Error.log has:
[Wed Jun 30 15:22:53 2010] [error] [client 127.0.0.1] File does not exist: /var/www/http-poll
"/tmp/rewrite.log" is empty.
I have enabled modules( including mod_rewrite) (a2enmod rewrite proxy proxy_http)
-
I notice that in your rewrite rule, the pattern to match ends with a slash, but the URL you accessed didn't. Try removing the slash from
http-poll/
in theRewriteRule
and see if that makes it work.: Same behaviour with: RewriteRule http-poll http://jabberserver:5280/http-poll [P] after apache2 restart. ie: [Wed Jun 30 18:34:05 2010] [error] [client 192.168.xx.xxx] File does not exist: /var/www/http-poll Thanks for the suggestion though.David Zaslavsky : Odd. I'd suggest enabling the rewrite log and setting its level to something verbose, and see what shows up in the log. Usually when I have rewriting problems, the information there shows exactly what's going wrong.From David Zaslavsky -
I think you need both to specify the absolute path, and ensure the pattern is at the beginning of the local path:
RewriteRule ^/http-poll/ http://jabberserver:5280/http-poll/ [P]
since otherwise the rewrite rule will apply again if the same Apache conf file interprets the proxy.
Additionally, if you want to redirect URLs under /http-poll/, you should specify regex substitutions:
RewriteRule ^/http-poll/(.*) http://jabberserver:5280/http-poll/$1 [P]
And, yes, this is definitely a Server Fault qn.
: I tried that and it did not work. I am going to go with a ProxyPass/ProxyPassReverse solution instead. Thanks for the help though.From Charles Stewart -
Shouldn't mod_rewrite.load only contain a line like this?
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
Anyway, it works for me if I put the rewrite rules in a server configuration (
<VirtualHost>
), but not if they're in the mod_rewrite.load (Ubuntu 8.04, Apache 2.2.8). If you don't use virtual hosts, try putting them in the<Directory>
section for your document root.: I tried to put it in the just inside theand then just inside the section to no avail. I think I am going to go with ProxyPass and ProxyPassReverse directives. From Brian
0 comments:
Post a Comment