【问题标题】:301 permanent redirect - all get variables301 永久重定向 - 所有获取变量
【发布时间】:2014-05-13 21:48:54
【问题描述】:

我有数百个不同类别的页面。是否可以为所有人编写一个 RewriteRule?我希望 301 重定向转到一页。

示例页面:

forms-category.html?category=trusts
forms-category.html?category=loans
etc..

全部永久重定向到一个页面:

RewriteRule ^forms-category.html?(?:.*)$    final.html  [L,NS,R=301]

【问题讨论】:

    标签: php .htaccess


    【解决方案1】:

    您可以在根 .htaccess 中使用此规则:

    RewriteEngine On
    
    RewriteCond %{QUERY_STRING} ^category=[^&]+
    RewriteRule ^forms-category\.html$ /final.html? [L,NC,R=301]
    

    【讨论】:

    • 从技术上讲,RewriteCond 是不必要的。你应该只需要这一行:RewriteRule ^forms-category\.html$ final.html? [L,NC,R=301]
    • 这不正确。重写条件是保证查询字符串中只有?category=trusts OR ?category=loans匹配。
    • 这些页面是示例页面,但问题本身表明有数百个页面需要重定向。很可能他不想具体列出每个页面。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-24
    • 2013-07-17
    • 1970-01-01
    • 2012-05-31
    • 2015-08-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多