Magento模块的URL重写 [英] URL rewriting for Magento module
问题描述
我在Magento中创建了一个新模块,并将其命名为"article".它有两个前端控制器索引和文章.
I have created a New Module in Magento and named it as "article". It has two Front end controllers index and article.
在文章控制器中,我有一个名为存档"的操作,可以根据档案库在前端/网站上列出文章.除了URL,其他一切都很好.
And in the article controller i have an action called "archives" to list the articles on the front end / website based on the archives. Everything is fine except the URL.
当前的工作网址为:[http://] mydemostore/article/article/archives/01/2011
The Working URL right now is : [http://]mydemostore/article/article/archives/01/2011
我真正需要的是 http://mydemostore/article/archives/01/2011
我不想有多余的文章"(控制器名称)
I don't want to have an extra "article" (the controller name)
我知道,因为我的模块名称和控制器名称相同,所以我得到了这个.如果我将自己的动作放在indexcontroller内,那我就完成了.但这没用.
I know since my module name and controller name are same i am getting this. If i would have placed my actions inside the indexcontroller, i would have got this done. But it was not working.
所以我现在需要的是我不想将动作从文章"控制器转移到索引"控制器,而只是想更改
So what i need right now is I don't want to move my actions from "article" to "index" controllers rather i just want to change
来自
[http://] mydemostore/article/article/archives/01/2011至
[http://]mydemostore/article/article/archives/01/2011 to
到
[http://] mydemostore/article/archives/01/2011
[http://]mydemostore/article/archives/01/2011
在.htaccess文件上使用Zend路由或基本的PHP URL重写.
using Zend routing or basic PHP URL rewriting on .htaccess file.
请帮助我如何使用这两种方法之一或同时使用这两种方法.
Kindly help me how to get this done by using either of these two ways or both the ways.
非常感谢您对我的问题进行检查!!!
Thanks a lot in advance for checking with my question !!!
推荐答案
I've not done this myself, only read about it here, but here goes...
在您的config.xml文件中:
In you config.xml file:
<config>
<global>
<rewrite>
<article_article_archives>
<from><![CDATA[#^/article/archives/#]]></from>
<to><![CDATA[/article/article/archives/]]></to>
</article_article_archives>
</rewrite>
</global>
</config>
节点<article_article_archives>
的格式不严格,只需要与其他重写唯一即可.
The node <article_article_archives>
isn't strictly formed, it only needs to be unique from other rewrites.
这篇关于Magento模块的URL重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!