0

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

To:

$baseUrl/my/design/5028

I have used the Magento's "URL Rewrite Management" to rewrite static URLs, without a problem. But it seems I cannot use dynamic parameters.

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;

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;

Thanks for any help.

4

1 回答 1

2

Yes, Magento's "URL Rewrite Managment" does not support dynamic links, afaik.

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();
}
于 2012-08-14T23:45:05.610 回答