mod_rewrite problem on apache2

mod_rewrite problem on apache2

am 10.06.2007 10:03:13 von deko

I'm trying to use rewrite rules on a Debian Etch apache2 web server. I turn
'RewriteEngine On' in apache2.conf and have my rewrite rules in httpd.conf. The
rule in httpd.conf is a test - to try and direct anything to /test/testpage.php
and log the redirect. But nothing is redirected or logged. What am I missing?

Here is my apache2.conf:

myserver [/etc/apache2] # cat apache2.conf
ServerRoot "/etc/apache2"
ServerName myserver
LockFile /var/lock/apache2/accept.lock
PidFile /var/run/apache2.pid
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
#keep traffic low for hosting on Comcast's network (default value is 100)
KeepAliveTimeout 15

StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0


StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0

User *****
Group *****
AccessFileName .htaccess

Order allow,deny
Deny from all

TypesConfig /etc/mime.types
DefaultType text/plain
HostnameLookups Off
ErrorLog /var/log/apache2/error.log
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
ServerSignature Off

Alias /icons/ "/usr/share/apache2/icons/"

Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all



IndexOptions FancyIndexing VersionSort HTMLTable NameWidth=*
DefaultIcon /icons/blank.gif
ReadmeName README.html
HeaderName HEADER.html
IndexIgnore .??* *~ *# RCS CVS *,v *,t


AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz


AddCharset us-ascii .ascii .us-ascii
AddCharset ISO-8859-1 .iso8859-1 .latin1
AddHandler type-map var
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
Include /etc/apache2/ports.conf
Include /etc/apache2/conf.d/
Include /etc/apache2/httpd.conf
Include /etc/apache2/sites-enabled/
Include /etc/phpmyadmin/apache.conf
RewriteEngine On
[end of file]

Here is my httpd.conf:

myserver [/etc/apache2] # more httpd.conf

Options +Indexes
Options +FollowSymlinks
RewriteRule ^(.*) /test/testpage.php
RewriteLogLevel 5
RewriteLog "/var/log/apache2/rewrite.log"

[end of file]

Re: mod_rewrite problem on apache2

am 10.06.2007 10:12:25 von deko

mod_rewrite is loaded and enabled

myserver [/etc/apache2/] # apache2ctl -t -D DUMP_MODULES
Loaded Modules:
core_module (static)
log_config_module (static)
logio_module (static)
mpm_prefork_module (static)
http_module (static)
so_module (static)
alias_module (shared)
auth_basic_module (shared)
authn_file_module (shared)
authz_default_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
cgi_module (shared)
dir_module (shared)
env_module (shared)
mime_module (shared)
python_module (shared)
negotiation_module (shared)
perl_module (shared)
php5_module (shared)
rewrite_module (shared)
setenvif_module (shared)
status_module (shared)
Syntax OK

myserver [/etc/apache2/mods-enabled] # ls -luchFA
total 0
lrwxrwxrwx 1 root root 28 2007-05-20 16:01 alias.load ->
.../mods-available/alias.load
lrwxrwxrwx 1 root root 33 2007-05-20 16:01 auth_basic.load ->
.../mods-available/auth_basic.load
lrwxrwxrwx 1 root root 33 2007-05-20 16:01 authn_file.load ->
.../mods-available/authn_file.load
lrwxrwxrwx 1 root root 36 2007-05-20 16:01 authz_default.load ->
.../mods-available/authz_default.load
lrwxrwxrwx 1 root root 38 2007-05-20 16:01 authz_groupfile.load ->
.../mods-available/authz_groupfile.load
lrwxrwxrwx 1 root root 33 2007-05-20 16:01 authz_host.load ->
.../mods-available/authz_host.load
lrwxrwxrwx 1 root root 33 2007-05-20 16:01 authz_user.load ->
.../mods-available/authz_user.load
lrwxrwxrwx 1 root root 32 2007-05-20 16:01 autoindex.load ->
.../mods-available/autoindex.load
lrwxrwxrwx 1 root root 26 2007-05-20 16:01 cgi.load ->
.../mods-available/cgi.load
lrwxrwxrwx 1 root root 26 2007-05-20 16:01 dir.conf ->
.../mods-available/dir.conf
lrwxrwxrwx 1 root root 26 2007-05-20 16:01 dir.load ->
.../mods-available/dir.load
lrwxrwxrwx 1 root root 26 2007-05-20 16:01 env.load ->
.../mods-available/env.load
lrwxrwxrwx 1 root root 27 2007-05-20 16:01 mime.load ->
.../mods-available/mime.load
lrwxrwxrwx 1 root root 33 2007-05-20 16:01 mod_python.load ->
.../mods-available/mod_python.load
lrwxrwxrwx 1 root root 34 2007-05-20 16:01 negotiation.load ->
.../mods-available/negotiation.load
lrwxrwxrwx 1 root root 27 2007-05-20 16:01 perl.load ->
.../mods-available/perl.load
lrwxrwxrwx 1 root root 27 2007-06-08 23:50 php5.conf ->
.../mods-available/php5.conf
lrwxrwxrwx 1 root root 27 2007-06-08 23:50 php5.load ->
.../mods-available/php5.load
lrwxrwxrwx 1 root root 30 2007-06-09 14:37 rewrite.load ->
.../mods-available/rewrite.load <<===****
lrwxrwxrwx 1 root root 31 2007-05-20 16:01 setenvif.load ->
.../mods-available/setenvif.load
lrwxrwxrwx 1 root root 29 2007-05-20 16:01 status.load ->
.../mods-available/status.load

Re: mod_rewrite problem on apache2

am 10.06.2007 11:35:57 von unknown

Post removed (X-No-Archive: yes)

Re: mod_rewrite problem on apache2

am 10.06.2007 12:14:40 von deko

> And if you put your rewrite rule right at the bottom of the
> apache2.conf what happens?

same behavior... ignored.

As far as I can tell, there is nothing wrong with this rule:

RewriteRule ^(.*) /test/testpage.php

>> myserver [/etc/apache2] # more httpd.conf
>>
>
> Something make me think that this 'if' fails.
>
> Try put the Rewrite directives at the bottom of the apache.conf file
> without the block

That's a reasonable troubleshooting step... had already tried it. I tried it
again... same results.

I figured httpd.conf was the appropriate place for the rewrite rules (not the
case?)
I have not yet tried putting them in a .htaccess file in the root directory -
was hoping to avoid that.

I had rewrite rules in httpd.conf with 1.3 and it worked great.

From what I've read about apache2, I need these:

RewriteEngine On
Options +Indexes
Options +FollowSymlinks

Since a2 has everything off (as opposed to a1.3 which had everything on) by
default.

but these directive are there.... what else could it be?

Re: mod_rewrite problem on apache2

am 10.06.2007 20:44:22 von HansH

"deko" schreef in bericht
news:-cCdneBPHpKVLfbbnZ2dnUVZ_uuqnZ2d@comcast.com...
> I'm trying to use rewrite rules on a Debian Etch apache2 web server. I
> turn 'RewriteEngine On' in apache2.conf and have my rewrite rules in
> httpd.conf. The rule in httpd.conf is a test - to try and direct anything
> to /test/testpage.php and log the redirect. But nothing is redirected or
> logged. What am I missing?
>
> Here is my apache2.conf:
> Include /etc/apache2/mods-enabled/*.load
> Include /etc/apache2/mods-enabled/*.conf
> Include /etc/apache2/ports.conf
> Include /etc/apache2/conf.d/
> Include /etc/apache2/httpd.conf
> Include /etc/apache2/sites-enabled/
> Include /etc/phpmyadmin/apache.conf
> RewriteEngine On
Odd place for this one ... might be too late

> Here is my httpd.conf:
>
> Options +Indexes
> Options +FollowSymlinks
IIRC 'RewriteEngine On' is needed here BEFORE a rule is set

> RewriteRule ^(.*) /test/testpage.php
> RewriteLogLevel 5
> RewriteLog "/var/log/apache2/rewrite.log"
>

> [end of file]
Do notice Debian's default installation gives you Apache2 in
virtualhost-mode, having a single virtualhost enabled at
/etc/apache2/sites-enabled.

If any virtualhost is acive Apache2 apparantly ignores rewrite* directives
in the server configuration.
It is my understanding the rewriterule(s) need to be (re)applied (by
Include-ing another file) within each virtualhost defined in any of the
linked files at /etc/apache2/sites-enabled/.

HansH