Mod_ReWrite / ReWriteMap a URL using a database lookup script

前端 未结 3 703
[愿得一人]
[愿得一人] 2021-01-17 04:40

The Scenario
I have completely rewritten an old existing ASP classic ecommerce website over to PHP.

The database design of the previous site had

3条回答
  •  北海茫月
    2021-01-17 05:07

    Your query:

    SELECT
      ID
    FROM
      thetable
    WHERE
      ProductID=?
    

    From there just echo the value of ID and a newline, and flush stdout.

    Rewrite rules:

    RewriteMap dbfixup prg:dbfixup.script
    RewriteCond %{QUERY_STRING} ProductID=(\d+)
    RewriteRule Product.asp Products.php?ID=${dbfixup:%1}
    

提交回复
热议问题