Reputation: 309
Edited .htacess:
RewriteEngine On
RewriteRule ^(.*)/(.*)/(.*)/(.*)/ api.php/$1/$2?param=$3&key=$4 [L]
RewriteRule ^(.*)/(.*)/(.*)/ api.php/$1/$2?param=$3 [L]
RewriteRule ^(.*)/(.*)/ api.php/$1/$2 [L]
This gives this error:
Internal Server Error
Update
This code works:
RewriteEngine On
RewriteRule ^(.*)/(.*)/(.*)/(.*)/ api.php/$1/$2?param=$3&key=$4 [L]
RewriteRule ^(.*)/(.*)/(.*)/ api.php/$1/$2?param=$3 [L]
Only when this line is added it crashes:
RewriteRule ^(.*)/(.*)/ api.php/$1/$2 [L]
Upvotes: 2
Views: 34
Reputation: 309
RewriteEngine On
RewriteRule ^(.*)/(.*)/(.*)/(.*)/ api.php/$1/$2?organisation=$3&key=$4 [L]
RewriteRule ^(.*)/(.*)/(.*)/ api.php/$1/$2?organisation=$3 [L]
RewriteRule ^(.*)/(.*)/$ api.php/$1/$2 [L]
The above solution is probably also working
Upvotes: 0
Reputation: 784898
It is causing 500 internal error because your rules are infinitely looping. This is because your pattern ^(.*)/(.*)/
also matches rewritten URI api.php/<whatever>/
.
You need to skip all rules for existing files and directories at top:
RewriteEngine On
# skip all files and directories from rewrite rules below
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^(.*)/(.*)/(.*)/(.*)/ api.php/$1/$2?param=$3&key=$4 [L,QSA]
RewriteRule ^(.*)/(.*)/(.*)/ api.php/$1/$2?param=$3 [L,QSA]
RewriteRule ^(.*)/(.*)/ api.php/$1/$2 [L,QSA]
I also suggest using anchor $
in your pattern to safeguard further.
Upvotes: 1