0

index.phpでリクエストを処理する方法

例えば

ブラウザにSEFと入力した場合

http://localhost/friends
http://localhost/me

に書き換えます

http://localhost/index.php/friends
http://localhost/index.php/me

だから私は$_REQUEST['PATH_lNFO']から友達や私にアクセスすることができました

私はmodを書き直して、apacheのルートディレクトリに設定されたすべてのディレクティブを許可しました。

.htaccessファイルが必要です。

4

2 に答える 2

1
RewriteRule ^friends$ index.php/friends [L]
RewriteRule ^me$ index.php/me [L]

それで全部です。

$_REQUEST['PATH_INFO']/friends「 」または「」に設定され/meます。

(サーバー構成によっては、ORIG_PATH_INFO代わりに使用する必要がある場合がありますPATH_INFO

于 2012-11-21T01:36:01.383 に答える
1

この記事 http://www.sitepoint.com/apache-mod_rewrite-examples/ でこのRewriteRule^/?([a-zA-Z _] +)/([a-zA-Z _] +)/([ a-zA-Z _] +)$ display.php?country = $ 1&state = $ 2&city = $ 3 [L]

AddDefaultCharset UTF-8
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /rtest
RewriteCond %{HTTP_HOST} ^mathpdq\.com
RewriteRule ^(.*)$ http://www.mathpdq.com/rtest/$1 [R=permanent,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

http://mathpdq.com/rtest/fred

于 2012-11-20T15:13:30.090 に答える