简体   繁体   English

如何在Magento中重写类别URL?

[英]How to rewrite category URL in Magento?

I have the following structure of categories: 我具有以下类别的结构:

default 默认
->myCategory1 -> myCategory1
-->SubCat11 -> SubCat11
---->Category111 ---->类别111
---->Category112 ---->类别112
-->SubCat12 -> SubCat12
........ ........
->myCategory2 -> myCategory2
-->SubCat21 -> SubCat21
---->Some_category ----> Some_category

Now my category URL is 现在我的类别网址是

http://<host_name>/myCategory1/SubCat11/Category11

or 要么

http://<host_name>/myCategory2/SubCat21/Some_category

I want to do category url structure like this: 我想做这样的类别网址结构:

http://<host_name>/SubCat11/Category111

or 要么

http://<host_name>/SubCat21/Some_category

Any ideas? 有任何想法吗?

Thanks. 谢谢。

Because your essentially trying to do this backwards, there is no foreseeable way to do this within Magento. 因为您实际上是在尝试向后执行此操作,所以在Magento中没有可预见的方法来执行此操作。

You might be able to get away with rewriting the URL within your .htaccess file. 您可能可以重写.htaccess文件中的URL。 You would typically create a rule as follows: 通常,您将创建如下规则:

RewriteRule ^/SubCat11/Category111/ /Category111/SubCat11 [L,R=301]

This does seem rather cumbersome. 这看起来确实很麻烦。 Perhaps it can be improved with wildcards: 也许可以使用通配符进行改进:

RewriteRule ^/([^/]+)/([^/]+)/ /$2/$1 [L,R=301]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM