【问题标题】:$this->url() to another subdomain$this->url() 到另一个子域
【发布时间】:2010-05-14 09:51:39
【问题描述】:

我为我的应用程序创建了子域。

host_www.type = "Zend_Controller_Router_Route_Hostname"
host_www.route = "www.mywebsite.com"
host_www.defaults.module = "default"
host_www.defaults.controller = "index"
host_www.defaults.action = "index"

store_infos.route = "storeinfos/:store"
store_infos.defaults.controller = "store"
store_infos.defaults.action = "store-infos"
store_infos.defaults.module = "default"
store_infos.chain = "host_www"

host_products.type = "Zend_Controller_Router_Route_Hostname"
host_products.route = "products.mywebsite.com"
host_products.defaults.module = "products"
host_products.defaults.controller = "products"
host_products.defaults.action = "index"

product_infos.type = "Zend_Controller_Router_Route_Regex"
product_infos.route = "([-\w]+).htm"
product_infos.reverse = "%s.htm"
product_infos.map.1 = "q"
product_infos.defaults.module = "products"
product_infos.defaults.controller = "products"
product_infos.defaults.action = "see-product"
product_infos.chain = "host_products"

我不知道这个 zend config ini 文件中的语法是否正确,尤其是路由链接。

一旦我进入这个子域,使用 $this->url() 构建的 url 如下所示:

<a href="<?= $this->url(array('store' => 1234), 'store_infos', true) ?>">
See store informations
</a>

仍然指向子域 products.mywebsite.com,我希望它指向 www.mywebsite.com

目前,我这样做:

<a href="http://www.mywebsite.com<?= $this->url(array('store' => 1234), 'store_infos', true) ?>">
See store informations
</a>

但是一点都不灵活。

有没有解决办法,加个参数,还是我的配置文件不对?

提前感谢您的帮助。

【问题讨论】:

  • 为什么这么多人在他们的代码中使用非英语的变量名/数组键?虽然这对于这个问题并不重要,但它使不说您的语言的人很难理解代码,因为理解变量/函数名称通常有助于理解代码。
  • 抱歉,忘记翻译许多变量。我理解你的观点,我同意。

标签: php zend-framework dns routes subdomain


【解决方案1】:

您可以在 index.php 中定义地址的服务器部分:

// Define the server
defined('APPLICATION_SERVER')
    || define('APPLICATION_SERVER', $_SERVER['SERVER_NAME']);

然后使用:

<a href="http://<?=APPLICATION_SERVER."/".$this->url(array('store'=>'1234'))?>">

【讨论】:

    猜你喜欢
    • 2019-07-02
    • 2019-04-09
    • 2015-01-05
    • 2020-07-27
    • 2018-07-28
    • 1970-01-01
    • 2021-10-22
    • 1970-01-01
    • 2019-01-12
    相关资源
    最近更新 更多