我想为SEO优化做URL。
My URL is: supplements.html?manufacturer=166
I want URL like: supplements/manufacturer/scivation.html(科学是id 166的制造商,补充类和制造商是属性)
任何帮助都将大大提前实现appreciated.Thanks。
发布于 2012-11-23 01:05:56
因为“补充剂”是一个类别(它改变了),如果不使用硬编码,那么使用一条写作规则就会更加困难。一个可能的解决方案是使用Mage::getModel('core/url_rewrite') (示例)为每个路径创建一个路由(使用此方法可能会遇到问题)。
另一个解决方案是更改url格式。
/制造商/补编/Scivation.html
然后创建一个自定义模块
config.xml
<global>
<rewrite>
<fancy_url>
<from><![CDATA[/manufacturer\/(.*)/(.*)/]]></from>
<to><![CDATA[manufacturer/index/processroute/manufacturername/$2/]]></to>
<complete>1</complete>
</fancy_url>
<rewrite>
</global>
<frontend>
<routers>
<tagseo>
<use>standard</use>
<args>
<frontName>customcategory</frontName>
</args>
</tagseo>
</routers>
class MageIgniter_Manufacturer_IndexController extends Mage_Core_Controller_Front_Action
{
public function processRoute(){
print_r($requestUri = Mage::app()->getRequest()->getRequestUri()); //supplements/scivation.html
print_r($this->getRequest()->getParam('manufacturername')); // scivation.html
print_r($this->getRequest())
// do you custom logic here base on about request path explode('/', trim($requestUri,'/'))
//lookup the attribute_id from attribute name
//if attribute_id found then try
//$this->_forward(string $action, [string|null $controller = null], [string|null $module = null], [ $params = null])
// to the catalog page
// else $this->_forward('defaultNoRoute');
}
...阅读更多@
使用Magento xml重写简单URL
https://stackoverflow.com/questions/13506042
复制相似问题