remove index.php from zend framework url(从 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 Zend 框架 url 中删除 index.php
基础教程推荐
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- php中的PDF导出 2022-01-01
- php中的foreach复选框POST 2021-01-01
- Web 服务器如何处理请求? 2021-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- 将变量从树枝传递给 js 2022-01-01
