$this->url() 到另一个子域

发布于 2024-09-01 16:40:40 字数 1596 浏览 4 评论 0原文

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

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() 构建的网址如下所示:

<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>

但它一点也不灵活。

有没有解决方案,要添加的参数,还是我的配置文件错误?

预先感谢您的帮助。

I created subdomain for my application.

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"

I don't know if the syntax in this zend config ini file is correct, in particular for routes chaining.

Once I'm on this subdomain, urls constructed with $this->url() like this :

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

still point to the subdomain products.mywebsite.com, where I want it to point to www.mywebsite.com

For the moment, I do this :

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

But it's not flexible at all.

Is there a solution, a parameter to add, or my config file is wrong ?

thanks in advance for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

素食主义者 2024-09-08 16:40:40

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

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

然后使用:

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

You could, in you index.php, define the server part of the address:

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

And then use:

<a href="http://<?=APPLICATION_SERVER."/".$this->url(array('store'=>'1234'))?>">
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文