首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >品牌上市需要URL重写

品牌上市需要URL重写
EN

Stack Overflow用户
提问于 2012-11-22 04:45:15
回答 1查看 2.3K关注 0票数 1

我想为SEO优化做URL。

代码语言:javascript
复制
My URL is: supplements.html?manufacturer=166
I want URL like: supplements/manufacturer/scivation.html

(科学是id 166的制造商,补充类和制造商是属性)

任何帮助都将大大提前实现appreciated.Thanks。

EN

回答 1

Stack Overflow用户

发布于 2012-11-23 01:05:56

因为“补充剂”是一个类别(它改变了),如果不使用硬编码,那么使用一条写作规则就会更加困难。一个可能的解决方案是使用Mage::getModel('core/url_rewrite') (示例)为每个路径创建一个路由(使用此方法可能会遇到问题)。

另一个解决方案是更改url格式。

/制造商/补编/Scivation.html

然后创建一个自定义模块

config.xml

代码语言:javascript
复制
<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

Magento路由器Url -需要合并路径名

MagentoV1.7网格视图-添加要查看的制造商属性

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13506042

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档