简体   繁体   中英

Magento custom URL Rewrite always matches category page after re-index

I have a blog MODULE installed on my Magento and it's URL is /blog.

I have a Blog CATEGORY in the nav bar with the URL /blog-away.html

I tried the URL Custom Rewrite and it works, until you re-index the site, then it reverts back to the category URL of /blog-away.html. I want the category to stay redirected to /blog.

Observations:

  1. the blog module does not use table "core_url_rewrite" - a least I didn't find any evidence.
  2. if the category and blog URLs are the same ("blog.html") - Magento routing will always first match the category and open the category page, you will never get the blog page.
  3. if the category has URL "blog.html" and the blog has, like, "wine-blog.html", you can't create a custom redirect from "blog.html" to "wine-blog.html". Magento will throw an error: "Request Path for Specified Store already exists." (the category's request_path is "blog.html")

So, given all that, I think it may work by setting up a redirect in the shop's root .htaccess file. But I've no clue what code to put in.

From your question I guess you have edited you URL Rewrite like this

Request Path: blog.html
Target Path: blog

Please follow this tutorial to create a new custom URL Rewrite with

Request Path: blog
Target Path: catalog/category/view/id/{blog category id}

And keep original URL Rewrite of Blog category as it is. Then since our custom URL Rewrite path is dependent on actual Category target path so Re-indexing won't effect it.

In

system->configuration->catalog

search for search engine optimizations

Edit product URL suffix and category URL suffix fields, replace .html to any other value or remove it.

Or use optimise web extension.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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