Apache JS => PHP处理

I need to process requests to

mysite.com/app.js?c=ClientID

via PHP - as it would come to

mysite.com/app.php?c=ClientID

it means set up RewriteRule to apache.

I've tried to use:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^(.*\.)(js)$ app.php?src=$1 [L,QSA]
</IfModule>

But I got

Bad Request

Your browser sent a request that this server could not understand. Client sent malformed Host header

There is the request

What I'm doing wrong?

Thank you

Fixed with this:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^app\.js$ /app.php?&%{QUERY_STRING}
</IfModule>

Thanks!

Try with below, assuming app.js non existing.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.js $1.php [QSA,L]

For bad request error you can check this article and also confirm you are using right apache version for using if directive such as <IfModule mod_rewrite.c> which is only supported in apache 2.4.