Reputation: 11
I have the following Rewrite Rules set up:
RewriteEngine On
RewriteRule ^api/([A-Za-z0-9-]+)$ index.php/api/$1 [NC,L]
RewriteRule ^([A-Za-z0-9-]+)$ index.php/other/$1 [NC,L]
Unfortunately these cause my server to throw a 500 error. Taken individually, they both work fine though.
My intention is that if the request is http://somesite.com/api/whatever/
, the first rule will get triggered, redirecting to index.php/api/whatever/
If anything other than "api" gets sent as the second segment though, it will redirect to index.php/other/whatever
.
Is my understanding flawed somehow? I thought that it would go down the list, and with the L flag, would stop executing once it hit something. Or is my syntax wrong?
Cheers
Upvotes: 1
Views: 974
Reputation: 39366
/var/log/httpd/error_log
(or the equivalent path on your system.)[NC]
flag makes [A-Za-z]
redundantTry:
RewriteRule ^api/([-A-Z0-9]+)$ index.php/api/$1 [NC,L]
RewriteRule ^([-A-Z0-9]+)$ index.php/other/$1 [NC,L]
Or perhaps
RewriteRule ^api/([^/]+)$ index.php/api/$1 [NC,L]
RewriteRule ^([^/]+)$ index.php/other/$1 [NC,L]
Upvotes: 2