如何从Zend Framework中的url中删除index.php

时间:2013-12-04 17:07:08

标签: .htaccess zend-framework

我正在使用Zend Framework 1.12开发此应用程序。我想用.htaccess摆脱index.php。现在我的网址看起来像这样:

http://foo.com:10080/Reports_Century/public/index.php/reports/neworders

我希望能够看起来像这样

http://foo.com:10080/Reports_Century/public/reports/neworders

有可能吗? 我的htaccess看起来有以下几行:

RewriteEngine On
RewriteCond% {REQUEST_FILENAME}-s [OR]
RewriteCond% {REQUEST_FILENAME}-l [OR]
RewriteCond% {REQUEST_FILENAME}-d
RewriteRule ^ .* $ - [NC, L]
RewriteRule ^ .* $ index.php [NC, L]
谢谢。

5 个答案:

答案 0 :(得分:1)

public/.htacess像这样:

RewriteEngine On
RewriteBase /Reports_Century/public/

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^(.+)$ index.php/$1 [L]

答案 1 :(得分:0)

尝试在RewriteEngine On

下面添加此权限
RewriteRule ^index\.php/(.+)$ /public/$1 [L,R]

答案 2 :(得分:0)

没有index.php的版本在Zend中是默认的。您不必更改默认.htaccess。 我打赌你没有在apache *中启用重写模块或在config中禁用重写。

*将rewrite.load文件复制到apache中的mods-enabled文件夹(在/etc/apache上的ubuntu上)

答案 3 :(得分:0)

终于找到问题所在。问题是在index.php /.

之后的1美元

最后的.htaccess是:

RewriteEngine On
RewriteBase /Reports_Century/public/

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^(.+)$ index.php [L]

@Anubhava为你提供了一个加时间来帮助我解决问题。

答案 4 :(得分:0)

您还需要激活" AllowOverride All"对于apache2/sites-enabled/default中的目录:

    <Directory /var/www/html/public>
            AllowOverride All
    </Directory>