はhttp://htaccess.madewithlove.be/によると、以下のルールセットは完璧に動作します:htaccessファイルは常に一致したルールを再適用し、ループで終わる
RewriteEngine On
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^images/([^\?]+)$ /_lib/mask_images.php [L]
RewriteRule ^search/([^\?]+)/merchant/([^\?]+)/brand/([^\?]+)/page/([^\?]+)$ /search.php?keyword=$1&merchant=$2&brand=$3&page=$4 [L]
RewriteRule ^search/([^\?]+)/brand/([^\?]+)/page/([^\?]+)$ /search.php?keyword=$1&brand=$2&page=$3 [L]
RewriteRule ^search/([^\?]+)/merchant/([^\?]+)/page/([^\?]+)$ /search.php?keyword=$1&merchant=$2&page=$3 [L]
RewriteRule ^search/([^\?]+)/page/([^\?]+)$ /search.php?keyword=$1&page=$2 [L]
RewriteRule ^search/([^\?]+)/brand/([^\?]+)$ /search.php?keyword=$1&brand=$2 [L]
RewriteRule ^search/([^\?]+)/merchant/([^\?]+)$ /search.php?keyword=$1&merchant=$2 [L]
RewriteRule ^search/([^\?]+)/merchant/([^\?]+)/brand/([^\?]+)$ /search.php?keyword=$1&merchant=$2&brand=$3 [L]
RewriteRule ^search/([^\?]+)$ /search.php?keyword=$1 [L]
RewriteRule ([^\?]+)/productID/([^\?]+)$ /detail.php?keyword=$1&productID=$2 [L]
RewriteRule ([^\?]+)$ /detail.php?keyword=$1 [L]
問題があること、最後の2つのルールが適用され、一致している、Apacheの再一致したルール(正しく割り当てられた引数)を適用し、無限ループに入ります。
私が追加:上記のルールセットへ
RewriteCond %{REQUEST_URI} !search.php$
RewriteCond %{REQUEST_URI} !detail.php$
RewriteCond %{REQUEST_URI} !index.php$
を。再度、htaccess testerのウェブサイトで検証して作業していれば、処理を停止し、引数として "detail.php"を出力します。ここで
は、リライト・ログはこう言われる、あなたが見ることができるように
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/hello -> hello
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] applying pattern '^images/(.*)$' to uri 'hello'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/hello -> hello
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] applying pattern '^search/(.*)/merchant/(.*)/brand/(.*)/page/(.*)$' to uri 'hello'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/hello -> hello
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] applying pattern '^search/(.*)/brand/(.*)/page/(.*)$' to uri 'hello'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/hello -> hello
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] applying pattern '^search/(.*)/merchant/(.*)/page/(.*)$' to uri 'hello'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/hello -> hello
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] applying pattern '^search/(.*)/page/(.*)$' to uri 'hello'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/hello -> hello
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] applying pattern '^search/(.*)/brand/(.*)$' to uri 'hello'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/hello -> hello
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] applying pattern '^search/(.*)/merchant/(.*)$' to uri 'hello'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/hello -> hello
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] applying pattern '^search/(.*)/merchant/(.*)/brand/(.*)$' to uri 'hello'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/hello -> hello
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] applying pattern '^search/(.*)$' to uri 'hello'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/hello -> hello
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] applying pattern '(.*)/productID/(.*)$' to uri 'hello'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/hello -> hello
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) [perdir /var/www/html/] applying pattern '(.*)$' to uri 'hello'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (2) [perdir /var/www/html/] rewrite 'hello' -> '/detail.php?keyword=hello'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (3) split uri=/detail.php?keyword=hello -> uri=/detail.php, args=keyword=hello
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (2) [perdir /var/www/html/] trying to replace prefix /var/www/html/ with/
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaabfcc50/initial] (1) [perdir /var/www/html/] internal redirect with /detail.php [INTERNAL REDIRECT]
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/detail.php -> detail.php
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] applying pattern '^images/(.*)$' to uri 'detail.php'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/detail.php -> detail.php
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] applying pattern '^search/(.*)/merchant/(.*)/brand/(.*)/page/(.*)$' to uri 'detail.php'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/detail.php -> detail.php
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] applying pattern '^search/(.*)/brand/(.*)/page/(.*)$' to uri 'detail.php'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/detail.php -> detail.php
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] applying pattern '^search/(.*)/merchant/(.*)/page/(.*)$' to uri 'detail.php'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/detail.php -> detail.php
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] applying pattern '^search/(.*)/page/(.*)$' to uri 'detail.php'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/detail.php -> detail.php
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] applying pattern '^search/(.*)/brand/(.*)$' to uri 'detail.php'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/detail.php -> detail.php
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] applying pattern '^search/(.*)/merchant/(.*)$' to uri 'detail.php'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/detail.php -> detail.php
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] applying pattern '^search/(.*)/merchant/(.*)/brand/(.*)$' to uri 'detail.php'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/detail.php -> detail.php
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] applying pattern '^search/(.*)$' to uri 'detail.php'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/detail.php -> detail.php
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] applying pattern '(.*)/productID/(.*)$' to uri 'detail.php'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/detail.php -> detail.php
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) [perdir /var/www/html/] applying pattern '(.*)$' to uri 'detail.php'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (2) [perdir /var/www/html/] rewrite 'detail.php' -> '/detail.php?keyword=detail.php'
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (3) split uri=/detail.php?keyword=detail.php -> uri=/detail.php, args=keyword=detail.php
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (2) [perdir /var/www/html/] trying to replace prefix /var/www/html/ with/
192.168.0.2 - - [11/Nov/2011:08:54:27 +0200] [website1.co.za/sid#2afe7a520d70][rid#2aaaaac0e0c0/initial/redir#1] (1) [perdir /var/www/html/] internal redirect with /detail.php [INTERNAL REDIRECT]
、再びそれが正しいルールと一致し、引数が正しく設定されているが、何らかの理由で、それは、その内部リダイレクトを再適用し、 (この例では "hello"です)からファイル名、detail.phpに変更する引数は、変更する必要があります。
私が現在知っているすべてのことから、これはどうすればいいのでしょうか? /検索がうまく動作するために働いています。
EDIT
これはdetail.phpに含まれるものである:
<?
echo $_GET["keyword"]."<br>";
echo $_GET["merchant"]."<br>";
echo $_GET["brand"]."<br>";
echo $_GET["page"]."<br>";
echo $_GET["productID"]."<br>";
exit();
?>
元の投稿を編集して詳細に含まれるコードを追加しました。PHP、search.php、index.php – user85569