$ this-> url () в другой поддомен - PullRequest
0 голосов
/ 14 мая 2010

Я создал поддомен для своего приложения.

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"

Я не знаю, правильный ли синтаксис в этом ini-файле zend config, в частности, для цепочки маршрутов.

Как только я попаду в этот поддомен, URL-адреса, созданные с помощью $ this-> 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>

Но это совсем не гибко.

Есть ли решение, параметр, который нужно добавить, или мой конфигурационный файл неверен?

Заранее благодарим за помощь.

1 Ответ

0 голосов
/ 20 июля 2013

Вы можете в вашем index.php определить серверную часть адреса:

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

А затем используйте:

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