I would like to configure my apache2.4.7 to redirect requests internally like this:
/app/download/somefile => /app/download.php/somefile
or sth comparable. After various attempts which all don't work I've come down to a very simple replacement which also simply refuses to work. I have added 2 lines to /etc/apache2/apache2.conf:
RewriteEngine on
RewriteRule "^/app/testtest\.php" "/app/index.php"
Didn't work. Then I've added the same thing inside a directory:
<Directory /var/www/html/app>
AllowOverride All
RewriteEngine on
RewriteRule "^/app/testtest\.php" "/app/index.php"
</Directory>
Same thing, just no effect. I had also tried this rule inside an .htaccess file, also no effect. /app/index.php exists, I'm sure I'm editing the right config (added syntax errors, then server doesn't come up when restarting) and I'm running out of ideas. I did not forget to enable the rewrite module, I executed
a2enmod rewrite
Any help is appreciated.
========================== UPDATE ============================
Ok, I made the rewrite part work by adding the following to sites-enabled/000-default.conf
RewriteEngine On
RewriteRule "^/app/(.+)" "/app/$1.php"
Don't know why it doesn't work in any other location but, fine, better than nothing. Now, I can access /app/index but not /app/index.php which would rewrite to /app/index.php.php which doesn't exist. So I added a condition
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule "^/app/(.+)" "/app/$1.php"
I read in several forums and documentation that this is the way to do it. But again, does not work at all. It doesn't work neither for php files (still can't access them with extention .php) nor for image files. Here is an extract from the logs:
script '/var/www/html/app/icons/bin_closed.png.php' not found or unable to stat
Why are my conditions being ignored? thanks for any hint.