2011-07-22 9 views
1

私は.htaccessファイルに次のようしている:私は、URLに入力する内容に関係なく、$1は私が起こることを期待するものは常にpage.php.htaccessはなぜターゲットページをここで変数として返すのですか?

に等しいしかし

RewriteEngine on 
RewriteBase/
RewriteRule ^(.*)$ page.php?query=$1 

myurl.com/test >> myurl.com/page.php?query=test 

何が起こっているか:

myurl.com/test >> myurl.com/page.php?query=page.php 
+0

それは私のために働く! – technology

答えて

1

リダイレクトが2回起こっている可能性があります。 page.php自体がpage.php?query=page.phpにリダイレクトされています。リダイレクトから除外する必要があります。さらに、既存のすべてのファイルとディレクトリを除外してください。また、後でファイルに書き込まれる可能性のある書き換えの処理を停止するには、[QSA'] to append any additional querystring params, as well as [L] `を追加します。

RewriteEngine on 
RewriteBase/

# if the request is NOT for a real file or directory 
# (page.php is a real existing file) 
# do the rewrite 
RewriteCond %{REQUEST_URI} !-f 
RewriteCond %{REQUEST_URI} !-d 
RewriteRule ^(.*)$ page.php?query=$1 [L,QSA] 
関連する問題