Hi,
I'm trying to rewrite URLs such as
https://api.rix-dev.cf//////////alert////?debug=true&/////ds=/////&a=b
to get rid of the unnecessary slashes in both the filename and query string.
There's a file called index.php within the document root which takes the GET parameter __method to know which method the user is calling - in this case, 'alert'.
Here's my .htaccess file:
RewriteEngine On
RewriteBase /
# Test: https://api.rix-dev.cf//////////alert////?debug=true&/////ds=/////&a=b
# Remove slashes in query string
RewriteCond %{QUERY_STRING} (.*)/(.*)
RewriteRule ^(.*)$ %{REQUEST_URI}?%1%2 [R=307,L]
# Remove double slashes from URL
RewriteCond %{THE_REQUEST} //
RewriteRule ^.*$ $0 [R=307,L]
# Remove 'index.php'
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=307,L]
# Put slash after filename; /alert?a=b -> /alert/?a=b
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)([^/])$ /$1$2/ [R=307,L]
# Add __method parameter
RewriteRule ^(.*)$ index.php?__method=$1 [NC,QSA]
The problem is that it's rewriting to
https://api.rix-dev.cf/?__method=alert&debug=true&ds=&a=b
...but should be rewriting to
https://api.rix-dev.cf/alert/?debug=true&ds=&a=b
...with '__method=alert' passed in the background. This works fine if 'RewriteRule ^(.*)$ %{REQUEST_URI}?%1%2 [R=307,L]' is commented out.
This seems to be happening because it's interfering with the query string, but I have no idea how to approach fixing it.
I'd really appreciate any help you can give with this. You can test what __method is being interpreted as by going to
https://api.rix-dev.cf/<anything>/?debug=true
and looking at 'debug-method'.
What I have tried:
Visiting many websites, which don't work for my specific situation