0

"http://localhost/jsfweb/cat/query/"こんにちは私はクエリがmysqlデータベースからいくつかの結果を返す文字列であるタイプのいくつかのURLに出くわしました。私はこのタイプのURLに精通していますが"http://localhost/jsfweb/cat.php?query=query"、phpでそれらのURLを使用するにはどうすればよいですか?

4

5 に答える 5

3

You can do this by rewriting url in htaccess file by this :

RewriteRule ^cat/(.*)$ cat.php?query=$1

于 2012-06-19T05:04:47.420 に答える
1

Use modrewrite

You do something like this: Inside a file named '.htaccess'

Options +FollowSymlinks
Options -MultiViews
RewriteEngine on
RewriteBase /php/eclipse/ShiftPlus2/

#forbidden area
#RewriteCond %{THE_REQUEST} index\.php
#RewriteRule ^index\.php$                               http://localhost/php/eclipse/ShiftPlus2/?   [R=301]

#unique case
RewriteRule ^email$ email.html [L]

#general case
RewriteRule ^([a-zA-Z_]*)/?$                                    index.php?query=$1                   [L]
RewriteRule ^([a-zA-Z_]+)/([a-z]+)/?$                           index.php?query=$1&action=$2          [L]
RewriteRule ^([a-zA-Z_]+)/(-?\d+)/?$                            index.php?query=$1&id=$2              [L]
RewriteRule ^([a-zA-Z_]+)/([a-z]+)/(-?\d+)/?$                   index.php?query=$1&action=$2$id=$3   [L]
RewriteRule ^([a-zA-Z_]+)/(\w+)/?$                              index.php?query=$1&special=$2         [L]

#RewriteRule ^index.php$ login [R]

Where on the left side, there is a Rewrite rule with a regular expression and on the right, this is the real link like you know.

于 2012-06-19T05:04:57.197 に答える
0

Apacheのmod_rewriteを見てください。ほとんどのWebサイトでは、そのモジュールを介して実行されます。手を汚したくない場合は、それを組み込んだある種のMVCフレームワークを採用できます。

于 2012-06-19T05:00:39.327 に答える
0

Apache mod_rewrite is what you want. This is an excellent read for beginners:

10 Mod Rewrite Rules You Should Know

于 2012-06-19T05:03:44.847 に答える
0

CodeIgniter (MVC framework) works by accepting a single entry point to the application, then routing according to what follows. So say you declare index.php as the default document, then /index.php/controller/view is the same as /controller/view. The parameters controller and view are used to instantiate and run the appropriate classes.

于 2012-06-19T05:06:37.453 に答える