How to avoid index.php in Zend Framework?
I'm using the Zend Router and so things like (/ and /index.php) or (/about and /index.php/about) ends up as the same here.
However, /index.php/whatever should not exist as it is the exactly same resource as /whatever so it doesn't make a sense the duplication.
How do I avoid this?
Even http://zendframework.com/manual/en/zend.controller开发者_JS百科.router.html and http://zendframework.com/index.php/manual/en/zend.controller.router.html both exists. It doesn't make any sense at all...
1) Don't link to it (like the urls in your question) and let it be a hidden feature. It won't matter, basically.
or
2) Add a rewrite-rule to strip out /index.php
from any request containing it. You have to be sure to forward it to index.php
so that you still can handle it, and you probably want to send a status code beginning with 3.
Seems that your mod_rewrite
is not configured properly (is mod_rewrite
enabled in Apache? Is .htaccess configured properly?
). When it would be, you wouldn't have to type index.php
at all.
Edit:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^index.php [OR]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
精彩评论