Apache > 2.2.22 rewrite rule not working?

Posted by EBAH on Server Fault See other posts from Server Fault or by EBAH
Published on 2013-10-11T17:22:25Z Indexed on 2014/06/11 9:28 UTC
Read the original article Hit count: 542

Filed under:
|
|
|
|

since yesterday I'm trying to figure out how to fix the following: running phpipam (http://www.phpipam.net/) with WAMP (Windows environment).

The problem I am facing is related with RewriteRule functionality, so forget phpipam for a moment and concentrate on few lines of code.

Here is the directory structure of my test website that emulate the first steps phpipam does (you can download http://goo.gl/ksvuGc):

C:\wamp\www\rewrite-tst\
C:\wamp\www\rewrite-tst\.htaccess
C:\wamp\www\rewrite-tst\index.php
C:\wamp\www\rewrite-tst\install
C:\wamp\www\rewrite-tst\install\index.php

It seems that the following rewrite rule in .htaccess doesn't work:

C:\wamp\www\rewrite-tst\.htaccess
# install
RewriteRule ^install$ install/ [R]
RewriteRule ^install/$ index.php?page=install

When opening C:\wamp\www\rewrite-tst\index.php the first step check the URL for "install" argument. Since the URL is:

http://localhost/rewrite-tst

no arguments are supplied and the browser is redirected to:

header("Location: /rewrite-tst/install/")

At this point the browser opens the page:

C:\wamp\www\rewrite-tst\install\index.php >> http://localhost/rewrite-tst/install

Apache, thanks to C:\wamp\www\rewrite-tst.htaccess should intercept this URL and redirect to:

http://localhost/rewrite-tst/index.php?page=install

Here are my tries:

  • Win Apache 2.2.22: works
  • Win Apache 2.4.4: KO
  • Win Apache 2.4.6: KO

In the attached zip file you can also find two traces from apache RewriteLog which I can't understand very well.

Why Apache 2.4 doesn't work on Windows? Is it possible that there's a bug on Windows version of Apache (2.4.4 and 2.4.6) or am I wrong someway?

Thanks for your help!!!

Evan

-- UPDATE 12 oct 2013

Now I'm really confused! Working on Linux, Kubuntu 13.04.

  • Linux Apache 2.2.22: works
  • Linux Apache 2.4.6: KO

I guess there's something wrong in my rules at this point, or some change happened from Apache 2.2 to 2.4 ...

© Server Fault or respective owner

Related posts about Windows

Related posts about mod-rewrite