簡體   English   中英

從zend框架網址中刪除index.php

[英]remove index.php from zend framework url

我正在使用zend框架開發模塊,並且已經使用zf create project命令創建了一個項目

當我嘗試使用ip/folder/controller/action訪問url時出現錯誤未找到錯誤我嘗試使用ip/folder/index.php/controller/action進行訪問時我能夠訪問,但我無法包含js ,在兩種情況下的css文件,我的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]

並且index.php是

<?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中:

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

用正確的路徑替換/ path / to /您的/安裝

我只是將其添加到index.php的頂部:

$_SERVER["REQUEST_URI"] = str_replace('index.php', '', $_SERVER["REQUEST_URI"]);

這是Akrabat.comRob Allen建議的另一種方法

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM