1

次のようなクエリ文字列を変換する必要があります。

http://localhost/view.php?id = 12345

これに:

http:// localhost / 12345

しかし、私はまた、次のように、検索エンジンが恩恵を受けるためにURLの最後に文字列を置くことを計画しています。

http:// localhost / 12345 / NameOfTheSkin

WowheadがURLを実行する方法のようなものです。

http://www.wowhead.com/item=49623/shadowmourne

文字列「shadowmourne」を任意の文字列に変更しても、アイテムIDを指すことに注意してください49623

基本的に、最後の文字列を無視する必要があります。

どんな助けでもありがたいです、乾杯。:)

4

1 に答える 1

5
RewriteRule ^/(\d+)/?.*$ /view.php?id=$1 [L]

これはに書き換えhttp://host/1234/some-textられhttp://host/1234ますhttp://host/view.php?id=1234

詳細な説明:

^   -- matches at the start of the string
(   -- start match group
\d+ -- match one or more digits
)   -- end match group
/?  -- match 0 or 1 slash
.*  -- match any character 0 or more times
$   -- matches at the end of the string

正規表現の完全なガイドについては、regular-expressions.infoにアクセスしてください。

于 2011-05-16T17:53:09.503 に答える