Score:0

Apache 2.4: ProxyPassMatch prevents mod_rewrite?

do flag

I try to setup a new development-environment in docker, with:

  • Bitnami Apache 2.4 - bitnami/apache:2.4
  • Bitnami PHP 8.0 - bitnami/php-fpm:8.0
  • Bitnami Mysql 5.7 - bitnami/mysql:5.7

The whole thing is up and running fine, except:

In my vhost.conf i redirect php-files to php-fcgi with ProxyPassMatch:

LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://php:9000/app/$1

My problem is, that I need to rewrite *.php-files in a subfolder "dbeS" to "index.php?id=filename". The RewriteRule in .htaccess looks like this:

  RewriteRule ^dbeS/(.*)\.php$ dbeS/index.php?id=$1 [QSA,L]

But it simply does not work. When I open in browser http://localhost/dbeS/mytest.php I should be redirected to http://localhost/dbeS/index.php?id=mytest. But instead he opens the http://localhost/dbeS/mytest.php (which is an empty file).

I read somewhere that the problem is, that ProxyPassMatch is executed before .htaccess so that .htaccess is completely ignored. So I schould have to activate php fcgi with filematch:

<FilesMatch \.php$>
  SetHandler "proxy:fcgi://php:9000/app/"
</FilesMatch>

But this does not work, too. Result is "File not found.". Is there an easy solution for this problem? I hope someone here has an idea how to solve this problem.
Bye, Jörg

I just solved the problem:

I had to change FilesMatch to: <FilesMatch .php$> SetHandler "proxy:fcgi://php:9000"

Then I had to put it inside the Virtualhosts. Additionaly I had wrong Portnumbers in my Virtualhost: I changed <VirtualHost *:80> to <VirtualHost *:8080> and <VirtualHost *:443> to <VirtualHost *:8443>. Now it seems to work as expected.

Mojo78 avatar
do flag
I just solved the problem: I had to change FilesMatch to: <FilesMatch .php$> SetHandler "proxy:fcgi://php:9000" Then I had to put it inside the Virtualhosts. Aditionally I had wrong portnumbers in my Virtualhost: I had <VirtualHost *:80> and had to change it to <VirtualHost *:8080> + <VirtualHost *:443> to <VirtualHost *:8443>. Now it seems to work as expected.
in flag
Great that you were able to solve your problem. But please don't edit the solution into your question, instead, post it as an answer and accept it. Otherwise the question will stay in the system as unsolved forever.
Score:0
do flag

I just solved the problem:

I had to change FilesMatch to: <FilesMatch .php$> SetHandler "proxy:fcgi://php:9000"

Then I had to put it inside the Virtualhosts. Additionaly I had wrong Portnumbers in my Virtualhost: I changed <VirtualHost *:80> to <VirtualHost *:8080> and <VirtualHost *:443> to <VirtualHost *:8443>. Now it seems to work as expected.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.