doufen5175 2012-12-02 17:46
浏览 6
已采纳

使用PHP获取值的简单mod重写

can someone tell me what in the world I'm doing wrong?

trying to take:

search.php?key=23&category=testing

and make:

/23/testing.html

with this:

RewriteRule ^([^/]*)/([^/]*)\.html$ /?key=$1&category=$2 [L]

For the life of me I can't figure this out...or if there is a better way, please point me in the right direction.

** UPDATE

Ok, after giving up on this I finally contacted the hosting company to see if there was a problem with my domain that was keeping this from working. Here is what they told me:

  1. You do not have a rewrite condition and you only have a simple rewrite. For the code to >always work properly you should normally set a "RewriteCond" with a valid pattern.

  2. You have used the "?" question mark character in your code although this is an escape >character and doing so would only cause a rewrite to index.php based upon your code as >everything after the question mark gets escaped.

Please consider using a "RewriteCond" in your code and also use regexes to properly escape >the "?" character and avoid unexpected behavior.

Can anyone give me some help? Thanks!

  • 写回答

1条回答 默认 最新

  • doufang2228 2012-12-02 18:23
    关注
    RewriteRule ^/([^/]*)/([^/]*)\.html$ /?key=$1&category=$2 [L,R]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 Java-Oj-桌布的计算
  • ¥15 请问如何在openpcdet上对KITTI数据集的测试集进行结果评估?
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路