douchuifk90315 2017-03-09 18:04
浏览 41
已采纳

的.htaccess; 如何重定向包含特定参数的所有子目录

How can I redirect all URL that contain value=123 and something to /maintenance.php?

Redirect e.g.:

www.example.com/something/myfile.php?value=123
www.example.com/something/thisfile.php?value=123

Don't redirect e.g.

www.example.com/something/myfile.php?value=999
www.example.com/something/myfile.php?test=999
www.example.com/folder/myfile.php?value=123

How can I do this with .htacces?

  • 写回答

1条回答 默认 最新

  • dongshuql24533 2017-03-09 18:08
    关注

    You can use this redirect rule to match a specific URI with a specific QUERY_STRING:

    RewriteEngine On
    
    RewriteCond %{THE_REQUEST} \s/+something/[^?]*\?value=123[&\s] [NC]
    RewriteRule ^ /maintenance.php? [R=302,L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?