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?

图片转代码服务由CSDN问答提供 功能建议

如何重定向包含 value = 123 something <的所有URL / code> to /maintenance.php

重定向例如:

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

不要重定向,例如

 <代码> www.example.com/something/myfile.php?value=999
www.example.com/something/myfile.php?test=999
www.example.com/folder  /myfile.php?value=123
nn

我如何使用 .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]
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题