dongta5621 2015-04-23 05:03
浏览 77

PHP变量到Wordpress商店页面

I have a link:

http://www.ignitionmarketing.co.za/products_promoDC.php?Product_Category=Corporate+Gifts

I would like it to be:

http://www.ignitionmarketing.co.za/product-category/corporate-gifts/

Also I have tried the normal way of:

Redirect 301 /products_promoDC.php?Product_Category=Corporate+Gifts http://www.ignitionmarketing.co.za/product-category/corporate-gifts/

But it still stays on a 404 page.

Could someone please help me?

Added Note:

I have a couple of other links that need to be redirected like:

/products_promoDC.php?Product_Category=Corporate+Clothing

/products_promoDC.php?Product_Category=Corporate+Clothing&Product_Subcategory=Shirts

The new WordPress shop does have the same categories as well.

  • 写回答

1条回答 默认 最新

  • dounuo9921 2015-04-23 08:54
    关注

    Just a better explanation to the solution. Maybe you come across a similar issue in the future.

    I redirected my "products_promoDC.php" to /product-category/ so the Variable/Parameter is then only loaded behind (/product-category/Corporate+Clothing/) this still gave me a 404 error because of the plus (+) within the URL. I simply then wrote a RewriteRule to convert the pluses (+) to dashes!

    Much easier than to do a RewriteMatch which could cause problems with the Subcategories.

    RewriteRule "^([^+]*)\++([^+]*\+.*)$" /$1-$2 [N]
    RewriteRule "^([^+]*)\++([^+]*)$" /$1-$2 [L,R=301]
    
    RewriteCond %{QUERY_STRING} Product_Category=([^&]+) [NC]
    RewriteCond %{QUERY_STRING} Product_Subcategory=([^&]+) [NC]
    RewriteRule products_promoDC\.php product-category/%1/? [L,R=301]
    

    I added a second line for my subcategories to load as well!

    Working perfectly: http://www.ignitionmarketing.co.za/products_promoDC.php?Product_Category=Corporate+Gifts

    评论

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)