簡體   English   中英

如何在zend框架的URL中刪除index.php

[英]How to remove index.php in url in zend framework

我最近從一個服務器到另一個服務器安裝了一個zend Framework網站。

eg: http://localhost/test/html ----  This is my website url

測試是我的文件夾----所有zend框架文件都保存在其中。...但是我的index.php文件在html文件夾下....而且我也在下面顯示index.php的代碼。 ..

我的網站通過此鏈接"http://localhost/test/html"成功運行

測試在哪里

這是我下面的.htaccess代碼

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

這是我在測試文件夾下的index.php文件

set_include_path('.'
        . PATH_SEPARATOR . get_include_path()
        . PATH_SEPARATOR . '../library'

//        . PATH_SEPARATOR . '../application/classes/'
//        . PATH_SEPARATOR . '../application/classes/forms/'
//        . PATH_SEPARATOR . '../application/models/'

          . PATH_SEPARATOR . '../application/default/classes/'
        . PATH_SEPARATOR . '../application/default/classes/forms/'
        . PATH_SEPARATOR . '../application/default/models/'
        . PATH_SEPARATOR . '../application/bo/classes/'
        . PATH_SEPARATOR . '../application/bo/classes/forms/'
        . PATH_SEPARATOR . '../application/bo/models/'
        . PATH_SEPARATOR . '../application/bo/controllers/'
        . PATH_SEPARATOR . '../application/helpers'
);

require_once "../library/Zend/Loader/Autoloader.php";
//session_start();
define("SITE_PATH", "http://localhost/test/");
define("SITE_BO_PATH", "http://localhsot/test/bo/");
define("URL", "/html/");
define("BO_URL", "/html/bo/");
define("BASE_URL", "/html/");
define("LIB_URL", "/library/");
define("IMG_URL", BASE_URL . "public/img/");
define("IMG_BO_URL", BASE_URL . "public/img_bo/");

@Zend_Loader::registerAutoload();

$options = array(
    'layout' => 'layout',
    'layoutContent' => '../application/views/layouts/',
    'contentKey' => 'content');


new DbInitialize();


date_default_timezone_set("Europe/Berlin");

Zend_Layout::startMvc($options);

Zend_Session::setOptions(array('save_path'=>'/vlk_session'));
if(isset($_COOKIE["Zend_Auth_RememberMe"]) && $_COOKIE["Zend_Auth_RememberMe"] !== false){
    Zend_Session::rememberMe("5302000");
    setcookie("Zend_Auth_RememberMe", false, time(), "/");
}



if(!Zend_Session::isStarted()){

    Zend_Session::start();

}



$sessionUUID = new Zend_Session_Namespace("vlk_jsessionId");
$sessionUUID->setExpirationSeconds(6000000);
if(!isset($sessionUUID->UUID)) {
    $sessionUUID->UUID = uniqid('vlk_');
}


$options = array(
    "adapter" => 'csv',
    "content" => 'languages/en.csv',
    "locale" => "en"
);

$translate = new Zend_Translate($options);
$_lingua = "it";

if(isset($_COOKIE["lingua"]) && ($_COOKIE["lingua"] == "it" || $_COOKIE["lingua"] == "en")){
    $_lingua = $_COOKIE["lingua"];
}
$translate->getAdapter()->setLocale($_lingua);
Zend_Registry::set('Zend_Translate', $translate);
$controller = Zend_Controller_Front::getInstance();
$_router = $controller->getRouter();


$_router->addRoute('backoffice',new Zend_Controller_Router_Route_Static('business',array('module' => 'bo','controller' => 'index','action' => 'index')));

$_router->addRoute('fanpage',new Zend_Controller_Router_Route_Static('business/fanpage',array('module' => 'bo','controller' => 'facebook','action' => 'index')));

$_router->addRoute('profile',new Zend_Controller_Router_Route_Static('business/profile',array('module' => 'bo','controller' => 'useredit','action' => 'profile')));

$_router->addRoute('video',new Zend_Controller_Router_Route_Static('business/video',array('module' => 'bo','controller' => 'gestionevideo','action' => 'lista')));





$fpcFrontendOptions = array(
                'lifetime' => 7200,
                'debug_header' => false,
                'regexps' => array(
                    '^/index/index/' => array('cache' => true)
                )
            );


            $fpcBackendOptions = array(
                'cache_dir' => 'tmp/'
            );
            $fullPageCache = new Zend_Cache_Frontend_Page($fpcFrontendOptions);
            $zcb = new Zend_Cache_Backend($fpcBackendOptions);
            $fullPageCache->setBackend($zcb);
            //echo "TEST CACHE";
            $fullPageCache->start();

//$controller->setControllerDirectory("../application/controllers");

$controller->setControllerDirectory(array(
            "default" => "../application/default/controllers",
            "bo" => "../application/bo/controllers"
            ));

$controller->throwExceptions(true); // should be turned on in development time 
// run!
$controller->dispatch();



?>

但是當我打電話給我的控制器時eg. http://localhost/test/index.php/cp eg. http://localhost/test/index.php/cp我只想刪除index.php文件。 在zend框架中的.htaccess文件或index.php文件中。

請給我任何建議。

歐米茄,是您的虛擬主機的文檔根嗎? 還是測試您的虛擬主機上的文件夾?

就像在Zend教程中一樣。 您需要在Apache中激活mod_rewrite並添加虛擬主機,如下所示:

<VirtualHost *:80>
  ServerName mypage.dev
  DocumentRoot /path/to/quickstart/public
  SetEnv APPLICATION_ENV "development"
  <Directory /path/to/quickstart/public>
    DirectoryIndex index.php
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

暫無
暫無

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

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