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 maixpy训练模型,模型训练好了以后,开发板通电会报错,不知道是什么问题
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容