Reputation: 174957
I have an application with a single point of entry. In that application, I have the following line:
$url = !empty($_SERVER["PATH_INFO"]) ? $_SERVER["PATH_INFO"] : "/";
This allows me to process URLs when I access them like so:
http://localhost/index.php/controller/action?get=variables
All is well, but the OCD I am, I want to get rid of the index.php
part of the URL. And no matter what I've tried, it didn't work as expected.
RewriteRule ^(.+)$ /index.php/$1 [L]
#or
RewriteRule ^([^.]+)$ /index.php/$1 [L]
etc.
Some of them produce a loop error in my nginx error log (too many rewrites), some of them just don't work at all.
I'm at a standstill here. How can I successfully rewrite such a URL? Note that I'm using Nginx and not Apache).
Upvotes: 1
Views: 92
Reputation: 798536
Negative lookahead.
RewriteRule ^(?!index\.php)(.*)$ /index.php/$1 [L]
Upvotes: 1