问题描述:

I'm gonna implement a new design / website structure for a customer, but I have a little problem. Since the URLs I've created are a bit different, I'm anticipating a problem with the SEO rankings due to the bunch of broken URLs. My idea is to match the existing URLs (from the old site) with the new ones I've created.

The problem I've stumbled upon is the following:

The old URLs are like http://www.example.com/category/numeric_id-item-name_item_code.html and the new URLs are likehttp://www.example.com/item_name-item_code.

In MySQL I created a new database containing on the first column the item_name and item_code from the old website and a second column the same info from the new database.

The idea is as it follows:

Example: Let's say we have an item named spring leaf with the code sl34. The old URL would be something like http://www.example.com/springs/53-spring-leaf-sl34.html.

For matching this URL there are 3 possibilities:

  1. If the product is in the new website http://www.example.com/spring-leaf-sl34
  2. In case they modified the name http://www.example.com/iron-spring-leaf-sl34
  3. In case the product is not in the new website: http://www.example.com/springs

I need help on creating these matches.

Thank you.

网友答案:

So, apparently, I've found some kind of quick fix:

CREATE
   VIEW `database`.`url_view` 
    AS
(SELECT old_table.old_url, new_table.new_url FROM old_table LEFT JOIN new_table ON old_table.product_code=new_table.product_code);

This will associate the old URLs with the new ones, and, if an old URL (product) is no longer available it will insert a (NULL) entry.

相关阅读:
Top