0

htaccessに以下のURLのURL書き換えルールを作りたいです。

http://example.com/vedios/category/fun/ -> http://example.com/vedios/category.php?cat=fun

http://example.com/vedios/category/fun/?show=popular -> http://example.com/vedios/category.php?cat=comedy&show=popular

http://example.com/vedios/category/fun/?show=popular&page=2 -> http://example.com/vedios/category.php?cat=comedy&show=popular&page=2

http://example.com/vedios/category/fun/comedy/ -> http://example.com/vedios/category.php?cat=comedy

http://example.com/vedios/category/fun/comedy/?show=popular -> http://example.com/vedios/category.php?cat=comedy&show=popular

http://example.com/vedios/category/fun/comedy/?show=popular&page=3 -> http://example.com/vedios/category.php?cat=comedy&show=popular&page=3

試しRewriteRule category/([^.]+)/?([^.]+)$ /vedio/category.php?cat=$1&$2てみましhttp://example.com/vedio/category.php?cat=fun&show=popular&page=1たが、うまくいきません。

上記の要件を満たす正しい URL 書き換えルールを教えてください。

4

2 に答える 2

4

RewriteRuleクエリは、ディレクティブ内でチェックされる URL パスの一部ではありません。RewriteCondそれを行うには、ディレクティブが必要です。

ただし、最初のクエリ文字列を新しいクエリ文字列に追加するには、 QSA フラグを設定する必要があります。

RewriteRule category/([^.]+)/$ /vedio/category.php?cat=$1 [QSA]
于 2009-07-06T10:28:21.453 に答える
0

カテゴリ スクリプトの正規表現:

/vedio/category/([^.]+)/\?([^.]+)$

mod_rewrite がすべての URL (サーバー + ポート + パス) を評価するか、スクリプトへのパスのみを評価するかによって異なります。

于 2009-07-06T10:22:01.513 に答える