I'm trying to configure rewrite rules with .htaccess
on an Azure Web App with Linux+Apache(+PHP), however I can only get redirects to work (but no rewrites).
The source is structured as following:
./.htaccess
./updates/
./updates/.htaccess
./updates/check/
./updates/check/api.php
./updates/certificates/
./updates/certificates/api.php
./... # other files - must not be downloadable
My ./.htaccess
is:
order deny,allow
deny from all
RewriteEngine on
RewriteRule "^updates/([A-Za-z]+)" "/updates/$1/api.php" [L,QSA]
EDIT: The problem also persists with
RewriteRule "^updates/([A-Za-z]+)$" "/updates/$1/api.php" [L,QSA]
My ./updates/.htaccess
is:
order allow,deny
allow from all
What I need, is to have an internal rewrite, that rewrites /updates/check?foo=bar
to /updates/check/api.php?foo=bar
and /updates/certificates?a=b&c=d
to /updates/certificates/api.php?a=b&c=d
.
What I get is a HTTP 301 Redirect to http://$server/updates/check/?foo=bar
. When I add R=301
(or R=302
) to the rule flags, I get an 301 (or 302) redirect to http://$server/updates/check/api.php?foo=bar
. Note the http
in both cases (I make an request to https with curl) and the entirely wrong rewrite in the first case.
I'm not sure if the client can handle redirects. This is why I'm trying to do an internal rewrite.
What do I have to do to get that rewrite working?