1

小さな Web アプリでクリーンな URL を設定しようとしています。現在、URL は次のようになっています。

http://www.mysite.com/productinfo.php?product=19

私はそれらをしたい:

http://www.mysite.com/productinfo.php?product=靴

RewriteMap と PHP スクリプトの両方を作成して、データベースのタイトル列をプルし、それを製品 ID の代わりに URL に挿入して、訪問者を楽しい方法で転送するにはどうすればよいでしょうか?

4

2 に答える 2

1

Well in this case, it doesn't look like you're going to need a URL rewrite, since you're just using the same $_GET variable.

Just check for the right title in the database when you interpret $_GET['product'], and find the right product id from there. I don't think you need Apache to solve this problem.

于 2012-03-22T14:12:07.630 に答える
0

このような単純な書き換えを使用できます-

RewriteEngine On
RewriteRule ^product/info/.*$ productinfo.php [NC,L]

htaccessファイル、vhost、またはその他の構成で-を使用します

$var = $_SERVER['REQUEST_URI'];

元のリクエストを取得します。これは非常に単純な例にすぎませんが、正しい方向に進むはずです。

于 2012-03-22T14:52:33.823 に答える