0

次のように読み取るURIがいくつかあります。

  1. http://www.domain.com/index.php?route=information/information&information_id=2(約)
  2. http://www.domain.com/index.php?route=information/information&information_id=4(ヘルプ)
  3. http://www.domain.com/index.php?route=information/information&information_id=7(連絡先)
  4. ...。

明示的であるが類似した書き換えルールの記述を回避する方法はありますか?

 RewriteRule    ^contact$    index.php?route=information/information&information_id=2    [NC,L]    # About

 RewriteRule    ^help$    index.php?route=information/information&information_id=4    [NC,L]    # Help
4

2 に答える 2

0

たくさんの可能性。最も簡単なのは次のようなものかもしれません:

^(.*)$ index.php?route=information/information&information_id=$1

次に、でinformation_id 文字列を処理しますindex.php。許容値のみを許可し、それ以外はすべて404を許可するようにしてください。

または、レベルをより制限するためにmod_rewrite

^(contact|help|foo)$ index.php?route=information/information&information_id=$1
于 2013-01-07T20:20:56.970 に答える
0

書き換えるページが数ページを超える場合、重要なのは、要求されたURLに基​​づいて正しいコンテンツを提供するために、インデックスページのロジックと組み合わせた単一の単純な書き換えルールを用意することです。

URL書き換えをサポートする一般的なCMSの.htaccessとindex.phpを見てください。そうすれば、探しているものが見つかります。

于 2013-01-07T20:22:24.083 に答える