我正在将过时的网址重定向到新的网址。
我使用以下三个RewriteRules动态生成产品页面网址:
# PRODUCT SUB-CATEGORY REDIRECT -- Must follow syntax: domain.com/products/CATEGORY/SUB-CATEGORY
RewriteRule ^products/([^/]*)/([^/]*)$ /product-subcategory.php?category=$1&sub-category=$2 [QSA,NC,L]
# PRODUCT CATEGORY REDIRECT -- Must follow syntax: domain.com/products/CATEGORY
RewriteRule ^products/([^/]*)$ /product-category.php?category=$1 [QSA,NC,L]
# PRODUCT CATEGORY REDIRECT WITH PAGE NUMBER
RewriteRule ^products/([^/]*)/page/([^/]*)$ /product-category.php?category=$1&page=$2 [QSA,NC,L]
以上方法正常工作。
现在,我正在尝试重定向此处显示的旧网址结构:
http://example.com/company/categories.cfm?c=Standard_Cabinet
到新页面,如下所示:
http://example.com/products/standard-cabinets
我试过这个RewriteRule
,没有成功:
RewriteRule ^company/categories.cfm?c=Standard_Cabinet$ http://www.example.com/products/standard-cabinets [R=301,NC]
我一直被重定向到我的404
页面。我不需要保留旧的URL参数
答案 0 :(得分:1)
使用:
RewriteCond %{QUERY_STRING} ^c=Standard_Cabinet$ [NC]
RewriteRule ^company/categories\.cfm$ http://www.example.com/products/standard-cabinets? [R=301,NC]