douzhang6646 2015-08-08 20:03
浏览 57
已采纳

使用htaccess更改带参数的URL

Like on the title, I'm looking for a way to change a url with parameters (from this www.animevid.net/player/?anime=d/dmc to this www.animevid.net/player/anime/d/dmc) using the .htaccess file.

I've found many similar post but I've only got errors, loop redirect, or...nothing. The nearest thing i've got is this code :

RewriteRule ^player/([0-9a-zA-Z_-]+)/([0-9a-zA-Z_-]+) player/index.html?anime=$1&t=$2 [NC,L]

Also please note the "d/dmc" on "?anime=d/dmc", is a variable, another example is "c/codegeass", "s/sao" etc...

  • 写回答

1条回答 默认 最新

  • dor65412 2015-08-08 20:33
    关注

    As mentioned above the final, rewritten url you give as an example is invalid. You should escape the last /:

    https://www.animevid.net/player/anime/d%2Fdmc
    

    and rewrite to:

    https://www.animevid.net/player/?anime=d%2Fdmc
    

    Then you have to change your regex strategy for this to work. Try something like that:

    RewriteEngine On
    RewriteRule ^player/([^/]+)/([^/]+) player/index.html?anime=$1&t=$2 [NC,L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)