如何删除“公开”从URL使用Zend框架中的路由 [英] How to remove "public" from url using routeing in zend framework

查看:105
本文介绍了如何删除“公开”从URL使用Zend框架中的路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的zend中有一个问题,我在.htaccess中写了一条规则,如下所述从网址中删除公共

An one issue in my zend, i write rule in .htaccess to remove "public" from url as following,

------------------------------------------------------------------------ 
RewriteEngine On

RewriteCond %{HTTP_HOST} ^domain-name.com/$ [OR]<br/>
ReWriteCond %{REQUEST_URI} !public/<br/>
ReWriteRule ^(.*)$ public/$1 [L]<br/>
------------------------------------------------------------------------ 

,但是zend中有ROUTE方法,我使用它来使用多种语言来设置URL像 www.domain-name.com/en / 中的语言代码,使用 zend_controller_router_route_chain

but there is ROUTE method in zend, i have use it for multiple language to set language code in url LIKE www.domain-name.com/en/ , using zend_controller_router_route_chain,

在实施此方法之前,我的网址是 www.domain-name.com

当我在zend项目中使用此方法时,可能是它覆盖了从网址中删除公共的.htaccess规则,或者使用该方法发生了某些事情,并且公共以类似 www.domain-name.com/的网址显示public

before this method implemented, my url is www.domain-name.com but
when i use this method in my zend project, may be it overwrites .htaccess rule of removing "public" from URL or something happen using same and "public" is displaying in url like www.domain-name.com/public.

那么在Zend框架中是否有任何方法或技巧可以通过使用 Route 的任何方法从URL中删除公众? ?

so IS THERE ANY METHOD OR TRICK TO REMOVE PUBLIC FROM URL USING ANY METHOD OF ROUTE IN ZEND FRAMEWORK ???

谢谢

MRJethva

推荐答案

以下内容使用ZF2.2对我有用

The following works for me using ZF2.2

在ZF2根目录上创建index.php ctory并添加以下内容:

Create index.php on ZF2 root directory and add the following content:

<?php 
define('RUNNING_FROM_ROOT', true);
include 'public/index.php';

在ZF2根目录上创建.htaccess并添加以下内容:

Create .htaccess on ZF2 root directory and add the following content:

SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteRule .* index.php

最后,在您的layout.phtml文件顶部添加以下条件语句:

Finally, add this conditional statement in the top of your layout.phtml file:

<?php 
if (defined('RUNNING_FROM_ROOT')) {
  $this->plugin('basePath')->setBasePath($this->basePath().'/public');
} ?>

享受!

参考: http://akrabat.com/zend-framework/zend-framework-on-a-shared -host /

这篇关于如何删除“公开”从URL使用Zend框架中的路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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