0

htaccess コードを使用する場合:

RewriteRule ^test/(.*)/?$ /taxis/index.php?location=$1 [L,QSA,NC,R]

リンクへのナビゲーション:

http://test.co.uk/test/abcde

htaccess が機能し、次の場所に転送されます: http://test.co.uk/taxis/index.php?location=abcde

ただし、同じディレクトリに適用されるように書き換えルールを変更したいと思います。

^taxis/(.*)/?$ /taxis/index.php?location=$1 [L,QSA,NC,R]

しかし、リンクに移動すると:

http://test.co.uk/taxis/abcde

リンクが機能せず、次のように生成されます。

http://test.co.uk/taxis/index.php?location=index.php&location=index.php&location=index.php&location=index.php&location=index.php&location=index.php&location=index.php&location=index.php&location=index.php&location=index.php&location=index.php&location=index.php&location=index.php&location=index.php&location=index.php&location=index.php&location=index.php&location=index.php&location=index.php&location=index.php&location=abcde

これを微調整して私に与える方法を知っていますか:

http://test.co.uk/taxis/index.php?location=abcde

4

1 に答える 1

1

URI が既に resource を指している場合、または単にルールのターゲットを除外する場合は、書き換えないように指示する書き換えルールの前に条件が必要です。書き換えエンジンは、URI が変化しなくなるまで、すべてのルールを継続的にループします。

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^taxis/(.*)/?$ /taxis/index.php?location=$1 [L,QSA,NC,R]

意味: 「リクエスト既存のファイルではなくリクエストが既存のディレクトリでもない場合、ルールを適用します」

または、ルールのターゲットを除外します。

RewriteCond %{REQUEST_URI} !^/taxis/index\.php$
RewriteRule ^taxis/(.*)/?$ /taxis/index.php?location=$1 [L,QSA,NC,R]
于 2013-04-23T19:10:02.340 に答える