从 Zend 框架 url 中删除 index.php [英] remove index.php from zend framework url

查看:20
本文介绍了从 Zend 框架 url 中删除 index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 zend 框架开发一个模块,并且我已经使用 zf create project 创建了一个项目命令

I am developing a module using zend framework and I have created a project using zf create project command

当我尝试使用 ip/folder/controller/action 访问 url 时,当我尝试使用 ip/folder/index.php/controller/访问时,它给出了错误未找到错误action 我可以访问,但在这两种情况下我都无法包含 js、css 文件,我的 htaccess 是

when i try to access the url using ip/folder/controller/action it is giving error not found error when i try access using ip/folder/index.php/controller/action i am able to access but i am unable to include js,css files in both cases and my htaccess is

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

和 index.php 是

and the index.php is

<?php

   // Define path to application directory
   defined('APPLICATION_PATH')
   || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/application'));

   // Define application environment
    defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') 
       ? getenv('APPLICATION_ENV') : 'production'));

   // Ensure library/ is on include_path
     set_include_path(implode(PATH_SEPARATOR, 
     array(realpath(APPLICATION_PATH . '/library'), get_include_path(),
)));

/** Zend_Application */
require_once 'Zend/Application.php';    

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()->run();

推荐答案

尝试将其添加到您的 .htaccess 中:

Try adding this to your .htaccess:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /([^/]+/)*index.php 
RewriteRule ^index.php(.*)$ /path/to/your/installation$1 [R=301,L]

用正确的路径替换/path/to/your/installation

Replace /path/to/your/installation with the correct path

这篇关于从 Zend 框架 url 中删除 index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆