1

私はフラッシュ ゲーム サイトを持っています。このサイトには play.php ファイルがあり、次の$_GETようにゲームの名前を取得します。

http://host/play.php?game=free-kick-puzzle

これはうまく機能しますが、Googleボットなどにはあまり適していないと思います.そして、他の多くのサイトがそうしていることがわかります.

host/games/free-kick-puzzle.php

gamename.phpこのファイルを自動的に「生成」する方法はありますか? ありがとう !

4

1 に答える 1

4

You don't want to "generate" files on the server, you just want to create nicer URLs that map to the ugly ones behind the scenes. One way to do that is by using rewrite rules.

Using an Apache module called mod_rewrite, you can make URLs more SEO friendly with directives you write in your .htaccess file.

In your .htaccess file, you could use code like this:

RewriteEngine on
RewriteRule ^games/(.*)/?$ /play.php?game=$1

This is just an example, and there are many other options available when using rewrite rules. I highly recommend looking at the documentation in the Apache docs about mod_rewrite.

In this example, you're finding anything after games/, represented by the parenthesis and the RegEx in between them. The /? means the trailing slash is optional. After the $ is what you actually want to serve to the visitor. The $1 is where whatever is found in between the parenthesis is placed.

于 2013-02-26T19:48:04.297 に答える