重写动态Magento URL [英] Rewrite dynamic Magento URL
问题描述
我在Nginx Web服务器上安装了Magento v1.4.1.1.我正在尝试重写以下动态网址:
I have a Magento v1.4.1.1 installation on Nginx web server. I'm trying to rewrite the following dynamic URL:
#5028 is the dynamic id passed in the URL
$baseUrl/design/index/index/design_id/5028
收件人:
$baseUrl/my/design/5028
我已经使用了Magento的"URL重写管理"来重写静态URL,没有问题.但是看来我不能使用动态参数.
I have used the Magento's "URL Rewrite Management" to rewrite static URLs, without a problem. But it seems I cannot use dynamic parameters.
我还尝试在server{}
位置内的Nginx配置上执行以下操作
I've also tried to do the following on Nginx configuration inside my server{}
location
rewrite ^/my/designs/([0-9]+)$ /design/index/index/design_id/$1 last;
但是它没有被抓住,如果我尝试访问http://mysite.com/my/design/5028
But it's not getting catch, I keep getting 404 errors if I try to access http://mysite.com/my/design/5028
此规则旁边的另一条规则非常有效
Another rule right next to this one works perfectly
rewrite ^(/fb)/design/([0-9]+)$ $1/landing_no_contest.php?design_id=$2? last;
感谢您的帮助.
推荐答案
是的,Magento的"URL重写管理"不支持动态链接,即afaik.
Yes, Magento's "URL Rewrite Managment" does not support dynamic links, afaik.
您可以通过编程方式为每个design_id
添加静态重写,
You could programmatically add static rewrites per design_id
to it, though:
$iStoreId = 1;
$sOptions = 'RP'; // 'RP' for a 301, or 'R' for a 302
$aDesignId = array(5026, 5027, 5028);
foreach ($aDesignId as $iDesignId) {
Mage::getModel('core/url_rewrite')
->setStoreId($iStoreId)
->setCategoryId(null)
->setProductId(null)
->setIdPath(str_replace('0.', '', str_replace(' ', '_', microtime())))
->setRequestPath('design/index/index/design_id/' . $iDesignId)
->setTargetPath('my/design/' . $iDesignId)
->setIsSystem(0)
->setOptions($sOptions)
->save();
}
这篇关于重写动态Magento URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!