2009年9月1日星期二

Re: [fw-mvc] disallow or redirect explicit reference to "index.php"

-- Yi Tang <ytang@mbira.com> wrote
(on Monday, 31 August 2009, 05:51 PM -0500):
> Is there a built-in way to disallow a user to explicitly type in
> "index.php" at the application root or re-route them to the application
> url without "index.php" specified?
>
> For example, for my given application www.example.com, both
> www.example.com and www.example.com/index.php show the same page. I'd
> like to either disallow www.example.com/index.php or have the requests
> redirect to their non-"index.php" counterparts.

Best way to do that is with a RewriteRule that matches "/index.php" and
redirects to "/", or a more robust one that takes any trailing
path/query information and redirects:

RewriteRule ^/?index.php(.*?)$ $1 [R]

--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/

没有评论: