douzhi6160 2018-03-26 22:14
浏览 52
已采纳

包含参数时的.htaccess重定向(“index.php?value = 2”)

Would anyone have suggestions on how to redirect a URL that has variables in it?

It looks like "www.homepage.com/index.php?value=home/index" would like it to simply redirect to "www.homepage.com"

I've tried:

Redirect /index.php?value=home/index /index

But it seems like "Redirect" ignores everything passed the question mark character. Is that so? Any way around it?

I am not familiar with regex, so I was hoping a simple solution is available without using that.

Thank you in advance :)

  • 写回答

1条回答 默认 最新

  • douji5523 2018-03-26 22:39
    关注

    To capture Query String like value=home/indexuse mod_rewrite

    Try this :

    RewriteEngine On
    RewriteCond %{QUERY_STRING} ^(.+)=(.+)/(.+)$
    RewriteRule ^     /?       [L,R]
    

    Redirect is mod_alias and that is designed to handle simple URL manipulation tasks. For more complicated tasks such as manipulating the query string, use the tools provided by mod_rewrite.

    https://httpd.apache.org/docs/2.4/mod/mod_alias.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题