0

私はいくつかのURLを次のように書き換えました:

RewriteRule ^futbol-video/([^/]*)-([^-]*)\.html$ /html/video.php?text=$1&id=$2 [L]

RewriteRule ^futbol-takimi/([^/]*)-([^-]*)\.html$ /html/takim.php?text=$1&id=$2 [L]

動的クエリを静的ページにリダイレクトしようとしています。以下のことを試しましたが、毎回内部サーバーエラーが発生します。フォーム 301 リダイレクトのルールはどのように記述すればよいですか?

最初に試しました:

RewriteRule ^futbol-video/([^/]*)-([^-]*)\.html$ /html/video.php?text=$1&id=$2 [R=301,L]

RewriteRule ^futbol-takimi/([^/]*)-([^-]*)\.html$ /html/takim.php?text=$1&id=$2 [R=301,L]

しかし、内部サーバーエラーが発生します。

4

1 に答える 1

0

クエリ文字列を正しく処理していないと思います。

クエリ文字列の処理に RewriteCond を利用する例については、次のブログ投稿を参照してください。

  1. http://www.simonecarletti.com/blog/2009/01/apache-query-string-redirects
  2. http://www.simonecarletti.com/blog/2009/01/apache-rewriterule-and-query-string/

ブログの例:

#Keep original query (default behavior)
RewriteRule ^page\.php$ /target.php [L]
# from http://example.com/page.php?foo=bar
# to   http://example.com/target.php?foo=bar

#Discard original query
RewriteRule ^page\.php$ /target.php? [L]
# from http://example.com/page.php?foo=bar
# to   http://example.com/target.php

#Replace original query
RewriteRule ^page\.php$ /target.php?bar=baz [L]
# from http://example.com/page.php?foo=bar
# to   http://example.com/target.php?bar=baz

#Append new query to original query
RewriteRule ^page\.php$ /target.php?bar=baz [QSA,L]
# from http://example.com/page.php?foo=bar
# to   http://example.com/target.php?foo=bar&bar=baz

編集 さらに、クエリ文字列を含む URL から静的ページに FROM をリダイレクトしようとしている場合、クエリ文字列を含む URL は、2 番目ではなく、書き換えルールで最初に来る (または書き換え条件に配置される) 必要があります。

于 2012-07-08T06:37:21.507 に答える