3

私の.htaccessファイルは次のとおりです。

Options -Multiviews
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php

それは機能しますが、私はそれがどのように機能するのか疑問に思っています。たとえば、と入力するとexample.com/main、でファイルを取得しますwww.example.com/main.php。コードの先頭にを.php追加した後に書き換えを停止するように指示されている場合、拡張子を取得するにはどうすればよいですか?www.example.com

編集:または、記憶されているユーザーにログインする目的でのみ一意のIDを作成する必要がありますか?

4

1 に答える 1

5

The particular behavior you're asking about comes about because the rule

RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

is a 301 redirect; it instructs the browser to initiate a completely new HTTP request. The L only causes (can only cause) it to be the last rule executed for that request; the new request comes in with the correct hostname and proceeds onward.

于 2012-06-27T15:12:12.667 に答える