1

次のようなものを渡したい(リダイレクトしない):

http://www.example.com/ (/ オプションあり) スクリプトに渡される http://www.example.com/index.php

http://www.example.com/foo/ (/ オプションで) スクリプトに渡される http://www.example.com/index.php?nav=foo

http://www.example.com/foo/bar (/ オプションあり) スクリプトに渡される http://www.example.com/index.php?nav=foo&subnav=bar

さらに、上記と同じパラメーターを使用して、サブドメインhttp://testumgebung.example.comhttp://www.example.com/testumgebung.phpに渡したいと思います。

私は次のことをなんとかしましたが、ブラウザバーのURLを渡された場所に書き換え、以前のようにURLを残しません:

RewriteCond %{HTTP_HOST}  ^testumgebung\.maskesuhren\.de
RewriteRule ^(.*)$ http://www.maskesuhren.de/$1/testumgebung.html [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/[^/]+/?$
RewriteRule ^([^/]*)/?$ index.html?nav=$1 [R,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /.*/.*
RewriteRule ^([^/]*)/([^/]*)$ index.html?nav=$1&subnav=$2 [R,L]
4

2 に答える 2

2

R最後の 2 つのルールを削除したい場合:

RewriteCond %{HTTP_HOST}  ^testumgebung\.maskesuhren\.de
RewriteRule ^(.*)$ http://www.maskesuhren.de/$1/testumgebung.html [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/[^/]+/?$
RewriteRule ^([^/]*)/?$ index.html?nav=$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /.*/.*
RewriteRule ^([^/]*)/([^/]*)$ index.html?nav=$1&subnav=$2 [L]

角括弧内のRは mod_rewrite にブラウザをリダイレクトするように指示します。これにより、ブラウザのロケーション バーの URL が変更されます。.

于 2013-10-22T14:46:38.407 に答える
1

私が望むものを達成するために順序を変更しなければならなかった

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/[^/]+/?$
RewriteRule ^([^/]*)/?$ ?nav=$1 [R,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /.*/.*
RewriteRule ^([^/]*)/([^/]*)$ ?nav=$1&subnav=$2 [R,L]

RewriteCond %{HTTP_HOST} ^testumgebung\. [NC]
RewriteRule ^$ testumgebung.html [L]

外部リソースがスラッシュで始まるように html を書き直します。

于 2013-10-24T11:11:26.023 に答える