When the RewriteRule is defined in Apache config instead of a .htaccess file, $_SERVER
['SCRIPT_NAME'] doesn't contain a filename and is equal to $_SERVER
['REQUEST_URI']. I'm not sure if it is a bug in PHP/Apache tandem or some very weird feature I wasn't aware of.
Reported by two people.
By Jörg Sandkuhle:
if i use the new RewriteRouter, i get an error
Warning: strpos() [function.strpos <http://develop/function.strpos>]:
Empty delimiter. in**
C:\apache\xampp\htdocs\develop\libs\zend\incubator\library\Zend\Controller\RewriteRouter.php
on line 67
Thats because if i use the url www.example.com, the
$_SERVER['SCRIPT_NAME'] is "/",
the basename from "/" is empty.
$base = $_SERVER['SCRIPT_NAME'];
if (strpos($_SERVER['REQUEST_URI'], basename($base)) === false)
Unknown macro: { $base = rtrim(dirname($base), '/'); }
$this->_rewriteBase = $base;
If i type www.example.com/test everything is ok.
And by Matthew Ratzloff:
With the pre-rewriteBase RewriteRouter everything worked great for me, but
now that the rewriteBase stuff has been added I can't get it to work at
all. This is using a version of the router I checked out just a couple
hours ago.
Here are some specific errors I'm getting (lines refer to RewriteRouter):
getCurrentRoute() on the root index throws this:
Fatal error: Uncaught exception 'Zend_Controller_Router_Exception' with
message 'Current route is not defined' [...] on line 84
The index page gives a warning:
Warning: strpos() [function.strpos]: Empty delimiter. [...] on line 63
And all routes (/controller/action, controller/action/key/value, special
routes defined with addRoute()) default to noRoute. The traditional
routes work just fine with the original router.
And I'm not sure if this is how rewriteBase is supposed to work, but
getRewriteBase() returns the full web path (minus domain). Manually
setting the rewriteBase with setRewriteBase() makes no difference.